Skip to content

Fix exception type thrown for non-existing absolute paths. #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ public Object prepare(Context context) throws PayloadNotFoundException {
}

private File getFile(Context context) throws FileNotFoundException {
File file = new File(data);
// check if data is an absolute path or a local app path and check if file exists:
File file = data.contains(File.separator) ? new File(data) : context.getFileStreamPath(data);

if (!file.exists()) {

// check if it's a local app file:
file = context.getFileStreamPath(data);
if (!file.exists()) {
throw new FileNotFoundException(String.format("File '%s' does not exist", data));
}
throw new FileNotFoundException(String.format("File '%s' does not exist", data));
}

return file;
Expand Down