Skip to content

[ai] Fix NPE in HybridFile toTrashBinRestoreFile and deletePermanentlyFromBin - #4761

Open
hoanle0126 wants to merge 1 commit into
TeamAmaze:release/4.0from
hoanle0126:fix/trashbin-restore-delete-npe-4135-4136
Open

hoanle0126 wants to merge 1 commit into
TeamAmaze:release/4.0from
hoanle0126:fix/trashbin-restore-delete-npe-4135-4136

Conversation

@hoanle0126

Copy link
Copy Markdown

Fixes #4135
Fixes #4136

Proposed Changes

  • Fall back to getFile().getName() in HybridFile.getName(Context) when mode == OpenMode.TRASH_BIN and name is null or empty (such as when constructed via new HybridFile(OpenMode.TRASH_BIN, path) in AppConfig.getTrashBinInstance()).
  • Guard HybridFile.toTrashBinRestoreFile(Context) against a null TrashBin instance or empty file name.
  • Guard HybridFile.deletePermanentlyFromBin(Context) when toTrashBinRestoreFile(Context) returns null so a singleton list containing null is not passed to TrashBin.deletePermanently(...).

Checklist

  • Respects the coding style (Run ./gradlew spotlessApply to format the code)
  • Tested Changes
  • Created Tests (If Applicable)
  • Does not add more than 300 lines of code (If more than 300 lines of code are added, please split the PR into smaller PRs)
  • Add a [ai] prefix to the PR title if AI was used to generate the code

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE on TrashBin#deletePermanently NPE on HybridFile#toTrashBinRestoreFile

2 participants