Repository navigation
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.14.0
Affected Android/Custom ROM version
Android 16
Affected device model
Xiaomi 17 pro max
How did you install the app?
F-Droid / IzzyOnDroid
Steps to reproduce the bug
- Have a folder
Pictures/Secretwith one image. - Long-press the folder → ⋮ → Lock folder → OK → PIN tab → enter
1234twice. The folder now shows the lock icon, and opening it asks for the PIN. - Long-press the folder → ⋮ → Rename. The app asks for the PIN; enter it. Rename the folder to
Secret2→ OK. - Force-stop the app, open it again and tap
Secret2.
Expected behavior
The renamed folder is still locked: it shows the lock icon and asks for the PIN.
Actual behavior
The lock icon is gone and Secret2 opens without asking for the PIN (also after restarting the app).
If the folder is renamed back to Secret, the lock icon comes back, so the lock is still stored under the old folder path.
Screenshots/Screen recordings
No response
Additional information
The lock is stored in preferences keyed by the folder path (protected_folder_hash_<path> / protected_folder_type_<path>):
https://github.com/FossifyOrg/Commons/blob/227e7d3cdea2343679eb0863bb597fc7a9200b4d/commons/src/main/kotlin/org/fossify/commons/helpers/BaseConfig.kt#L207-L225
The single-folder rename asks for the PIN, then updates the Directory item and its DB row, but does not move the lock to the new path:
Gallery/app/src/main/kotlin/org/fossify/gallery/adapters/DirectoryAdapter.kt
Lines 309 to 338 in ea7499d
| private fun renameDir() { | |
| if (selectedKeys.size == 1) { | |
| val firstDir = getFirstSelectedItem() ?: return | |
| val sourcePath = firstDir.path | |
| val dir = File(sourcePath) | |
| if (activity.isAStorageRootFolder(dir.absolutePath)) { | |
| activity.toast(org.fossify.commons.R.string.rename_folder_root) | |
| return | |
| } | |
| activity.handleLockedFolderOpening(sourcePath) { success -> | |
| if (success) { | |
| RenameItemDialog(activity, dir.absolutePath) { | |
| activity.runOnUiThread { | |
| firstDir.apply { | |
| path = it | |
| name = it.getFilenameFromPath() | |
| tmb = File(it, tmb.getFilenameFromPath()).absolutePath | |
| } | |
| updateDirs(dirs) | |
| ensureBackgroundThread { | |
| try { | |
| activity.directoryDB.updateDirectoryAfterRename(firstDir.tmb, firstDir.name, firstDir.path, sourcePath) | |
| listener?.refreshItems() | |
| } catch (e: Exception) { | |
| activity.showErrorToast(e) | |
| } | |
| } | |
| } | |
| } |
The multi-folder rename in the same function skips protected folders (!config.isFolderProtected(it), L342), so a rename is clearly not meant to drop the lock. And since the rename happens inside Gallery, the app knows the old and new path; for file renames it already moves the path-keyed media and favorites rows (updateDBMediaPath):
Gallery/app/src/main/kotlin/org/fossify/gallery/extensions/Context.kt
Lines 1033 to 1041 in ea7499d
| fun Context.updateDBMediaPath(oldPath: String, newPath: String) { | |
| val newFilename = newPath.getFilenameFromPath() | |
| val newParentPath = newPath.getParentPath() | |
| try { | |
| mediaDB.updateMedium(newFilename, newPath, newParentPath, oldPath) | |
| favoritesDB.updateFavorite(newFilename, newPath, newParentPath, oldPath) | |
| } catch (ignored: Exception) { | |
| } | |
| } |
Possible fix: in renameDir, if the old path is protected, call addFolderProtection(newPath, hash, type) with the old values and removeFolderProtection(oldPath).
Activity