Skip to content

Commit

Permalink
Don't keep calling getRealPath if it's not a dir or fails
Browse files Browse the repository at this point in the history
  • Loading branch information
TuxPaper committed Sep 7, 2023
1 parent 01fb448 commit 1b92aa5
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ private static long queryForLong(Context context, Uri self, String column,
return defaultValue;
}
} catch (Exception e) {
Log.w(TAG, "Failed query: " + e);
Log.w(TAG, "Failed queryForLong: " + e);
return defaultValue;
} finally {
closeQuietly(c);
Expand Down Expand Up @@ -1010,7 +1010,7 @@ private Uri getFirstFileUri() {
return documentUri;
}
} catch (Exception e) {
Log.w(TAG, "Failed query: " + e);
Log.w(TAG, "Failed getFirstFileUri query: " + e);
} finally {
closeQuietly(c);
}
Expand All @@ -1029,27 +1029,27 @@ private Uri getFirstFileUri() {
private String getRealPath() {
try {
if (!docFile.isDirectory()) {
return null;
return path;
}
Uri uri = getFirstFileUri();
if (uri == null) {
DocumentFile tmp = docFile.createDirectory("tmp");
if (tmp == null) {
return null;
return path;
}
uri = tmp.getUri();
tmp.delete();
}
String path = uri.toString();
int i = path.lastIndexOf("%2F");
String newPath = uri.toString();
int i = newPath.lastIndexOf("%2F");
if (i < 0) {
return null;
return path;
}
path = path.substring(0, i);
return path;
newPath = newPath.substring(0, i);
return newPath;
} catch (Throwable t) {
loge("getRealPath", t);
return null;
return path;
}
}

Expand Down

0 comments on commit 1b92aa5

Please sign in to comment.