Repository navigation
Storage category: a file deleted during a search is listed again when the search is cleared #518
Description
Checklist
- I can reproduce the bug with the latest version given here.
- I made sure that there are no existing issues - open or closed - to which I could contribute my information.
- I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
- I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
- I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
- This issue contains only one bug.
- I have read and understood the contribution guidelines.
Affected app version
1.6.3
Affected Android/Custom ROM version
Android 16
Affected device model
Xiaomi 17
How did you install the app?
F-Droid / IzzyOnDroid
Steps to reproduce the bug
- Have
report-alpha.txtandreport-gamma.txtin a folder, so that both are listed under Storage → Documents. - Storage tab → Documents → Search → type
report-. Both files are listed. - Long-press
report-gamma.txt→ Delete → Yes. It disappears from the results. - Tap the clear (×) button in the search field.
- Tap
report-gamma.txt.
Expected behavior
report-gamma.txt is not listed after the search is cleared.
Actual behavior
After step 4 the full list shows report-gamma.txt again. Tapping it (step 5) opens an empty editor for a file that no longer exists. The row goes away only after Documents is reopened.
Screenshots/Screen recordings
No response
Additional information
During a search, the adapter shows a filtered copy of storedItems:
File-Manager/app/src/main/kotlin/org/fossify/filemanager/activities/MimeTypesActivity.kt
Lines 157 to 176 in 7f074fe
| else -> { | |
| ensureBackgroundThread { | |
| if (lastSearchedText != searchNormalizedText) { | |
| return@ensureBackgroundThread | |
| } | |
| val listItems = storedItems.filter { | |
| it.name.normalizeString().contains(searchNormalizedText, true) | |
| } as ArrayList<ListItem> | |
| runOnUiThread { | |
| getRecyclerAdapter()?.updateItems(listItems, text) | |
| binding.apply { | |
| mimetypesFastscroller.beVisibleIf(listItems.isNotEmpty()) | |
| mimetypesPlaceholder.beVisibleIf(listItems.isEmpty()) | |
| mimetypesPlaceholder2.beGone() | |
| } | |
| } | |
| } | |
| } |
Delete removes the item from the adapter's list only; deleteFiles in MimeTypesActivity does not update storedItems, and clearing the search restores storedItems, which still contains the deleted file:
File-Manager/app/src/main/kotlin/org/fossify/filemanager/activities/MimeTypesActivity.kt
Lines 123 to 146 in 7f074fe
| override fun deleteFiles(files: ArrayList<FileDirItem>) { | |
| deleteFiles(files, false) { | |
| if (!it) { | |
| runOnUiThread { | |
| toast(R.string.unknown_error_occurred) | |
| } | |
| } | |
| } | |
| } | |
| override fun selectedPaths(paths: ArrayList<String>) {} | |
| fun searchQueryChanged(text: String) { | |
| val normalizedText = text.normalizeString() | |
| val searchNormalizedText = normalizedText.trim() | |
| lastSearchedText = searchNormalizedText | |
| when { | |
| searchNormalizedText.isEmpty() -> { | |
| binding.apply { | |
| mimetypesFastscroller.beVisible() | |
| getRecyclerAdapter()?.updateItems(storedItems) | |
| mimetypesPlaceholder.beGoneIf(storedItems.isNotEmpty()) | |
| mimetypesPlaceholder2.beGone() | |
| } |
Possible fix: remove the deleted paths from storedItems in deleteFiles (or reload the items after the delete).
Activity