Skip to content

Commit 015f7cf

Browse files
committed
Avoid SMB rename checks on the UI thread
The rename completion path in MainActivityHelper re-checked success by calling newFile.exists(context) on the UI thread because SAF-backed renames can report false negatives. For SMB targets that fallback routes into HybridFile.exists() and performs synchronous network I/O on the main thread. Limit the fallback probe to SAF-backed targets and cover it with a focused regression test. Constraint: Preserve the post-rename verification workaround for SAF-backed rename targets Rejected: Change HybridFile.exists() semantics for all SMB callers | too broad and would affect background operations that legitimately rely on it Confidence: high Scope-risk: narrow Directive: Keep rename completion fallbacks off the UI thread for remote backends; only use exists(context) as a SAF-specific verification path Tested: ./gradlew :app:testFdroidDebugUnitTest --tests com.amaze.filemanager.utils.MainActivityHelperTest -x kaptFdroidDebugUnitTestKotlin Tested: ./gradlew :app:compileFdroidDebugJavaWithJavac Tested: ./gradlew :app:compileFdroidDebugUnitTestJavaWithJavac -x kaptFdroidDebugUnitTestKotlin Not-tested: Full :app:testFdroidDebugUnitTest (blocked by existing kaptFdroidDebugUnitTestKotlin failure in unrelated tests referencing missing ShadowMultiDex)
1 parent e1e5619 commit 015f7cf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/src/main/java/com/amaze/filemanager/utils/MainActivityHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ public void done(final HybridFile hFile, final boolean b) {
388388
* DocumentFile.renameTo() may return false even when rename is successful. Hence we need an extra check
389389
* instead of merely looking at the return value
390390
*/
391-
if (b || newFile.exists(context)) {
391+
if (b
392+
|| ((newFile.isDocumentFile() || newFile.isOtgFile())
393+
&& newFile.exists(context))) {
392394
Intent intent = new Intent(MainActivity.KEY_INTENT_LOAD_LIST);
393395

394396
intent.putExtra(

0 commit comments

Comments
 (0)