Skip to content

Fix file rename in drawer views#4584

Open
geoffreysisco wants to merge 1 commit into
TeamAmaze:release/4.0from
geoffreysisco:fix/failed-drawer-rename-file
Open

Fix file rename in drawer views#4584
geoffreysisco wants to merge 1 commit into
TeamAmaze:release/4.0from
geoffreysisco:fix/failed-drawer-rename-file

Conversation

@geoffreysisco
Copy link
Copy Markdown
Contributor

@geoffreysisco geoffreysisco commented Mar 13, 2026

Use file mode and parent directory from the selected item when invoking rename instead of fragment navigation state.

Description

Rename operations launched from drawer category views could fail with
Operation Unsuccessful even when the same file could be renamed
successfully from a normal filesystem directory.

MainFragment.rename() was invoking rename using the fragment's current
navigation state:

  • mainFragmentViewModel.getOpenMode()
  • mainFragmentViewModel.getCurrentPath()

In drawer category views, those values represent the current category
view rather than the selected file's actual filesystem location.

This change uses the selected item's filesystem context instead:

  • file mode via f.getMode()
  • parent directory via f.getParent(requireContext())

Rename operations now resolve against the selected file's actual
location rather than the fragment's current navigation state.

Issue tracker

Fixes #4560

Automatic tests

  • Added test cases

Manual tests

  • Done

  • Device: Pixel 9 Pro emulator

  • OS: Android 16

  • Rooted: No

  • Version: 3.11.2

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembleDebug
  • ./gradlew spotlessCheck

@geoffreysisco geoffreysisco force-pushed the fix/failed-drawer-rename-file branch from f8cd402 to 5c69d7f Compare March 13, 2026 00:37
@VishnuSanal VishnuSanal added the PR-Awaiting-Initial-Review this PR is awaiting for an initial review label Mar 21, 2026
VishnuSanal
VishnuSanal previously approved these changes Mar 22, 2026
Copy link
Copy Markdown
Member

@VishnuSanal VishnuSanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 thanks!

@VishnuSanal VishnuSanal added PR-Awaiting-Final-Review this PR is awaiting a final review/approval and removed PR-Awaiting-Initial-Review this PR is awaiting for an initial review labels Mar 22, 2026
Copy link
Copy Markdown
Member

@EmmanuelMess EmmanuelMess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use File to get the parent, use the hybrid file to prevent issues with remote modes and DocumentFile. I am not quite sure if you don't need to check if its remote or DocumentFile in this case.

Use file mode and parent directory from the selected item when invoking rename instead of fragment navigation state.

Use HybridFile parent handling so rename follows Amaze filesystem abstractions for remote modes and DocumentFile-backed paths.
@geoffreysisco
Copy link
Copy Markdown
Contributor Author

Updated — I removed the raw File parent lookup and now use the selected HybridFileParcelable’s inherited HybridFile.getParent(Context) handling instead.

That method already branches by OpenMode, including SMB/SFTP and DOCUMENT_FILE, so the rename call site does not need to add separate remote or DocumentFile checks here. The rename flow still passes the selected item’s mode/path, preserving the drawer-view fix while keeping parent resolution inside Amaze’s filesystem abstraction.

Verified with:

  • ./gradlew spotlessApply
  • ./gradlew spotlessCheck
  • manual drawer/category rename test on Pixel 9 Pro emulator, Android 16
  • rotation tested; no crash observed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Awaiting-Final-Review this PR is awaiting a final review/approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename not work in "Audios", "APKs", etc.

3 participants