Skip to content

Renaming a locked folder silently removes its lock #1195

Open

Description

@XYIheng

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

  1. Have a folder Pictures/Secret with one image.
  2. Long-press the folder → ⋮ → Lock folder → OK → PIN tab → enter 1234 twice. The folder now shows the lock icon, and opening it asks for the PIN.
  3. Long-press the folder → ⋮ → Rename. The app asks for the PIN; enter it. Rename the folder to Secret2 → OK.
  4. 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:

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):

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

  1. added
    bug
    needs triage
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions