{"record":{"id":"d4ea7cec3cc7f415","repo":"beemdevelopment/Aegis","slug":"unable-to-delete-directory-s","errorCode":null,"errorMessage":"Unable to delete directory: %s","messagePattern":"Unable to delete directory: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/beemdevelopment/aegis/icons/IconPackManager.java","lineNumber":223,"sourceCode":"        if (latestVersion == -1) {\n            return null;\n        }\n\n        return new File(packDir, Integer.toString(latestVersion));\n    }\n\n    private static void deleteDir(File dir) throws IOException {\n        if (dir.isDirectory()) {\n            File[] children = dir.listFiles();\n            if (children != null) {\n                for (File child : children) {\n                    deleteDir(child);\n                }\n            }\n        }\n\n        if (!dir.delete()) {\n            throw new IOException(String.format(\"Unable to delete directory: %s\", dir));\n        }\n    }\n}\n","sourceCodeStart":205,"sourceCodeEnd":227,"githubUrl":"https://github.com/beemdevelopment/Aegis/blob/d6f4e5925a97e4e91593f1542085eae03432a759/app/src/main/java/com/beemdevelopment/aegis/icons/IconPackManager.java#L205-L227","documentation":"IconPackManager.deleteDir recursively deletes an icon pack directory and, after removing all children, calls dir.delete(). If that final delete fails — files re-created concurrently, open file handles, or read-only filesystem — it throws an IOException naming the directory. It is invoked by removeIconPack and recursively by itself for subdirectories.","triggerScenarios":"dir.delete() returning false during removeIconPack: the directory is not empty because a file appeared during traversal, a file handle is still open, or the storage is read-only/unmounted.","commonSituations":"Removing an icon pack while its icons are still referenced/open by another component; external storage mounted read-only or pulled mid-delete; filesystem left inconsistent after a crash.","solutions":["Retry the icon pack removal after closing other Aegis screens/background work","Reboot the device to release file handles, then remove the pack again","Check the storage is writable; remount external storage if read-only","Manually clear Aegis's data/cache if the directory remains stuck"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"File dir = getIconPackDir(pack);\nif (!dir.exists()) return; // nothing to delete\nif (!dir.canWrite()) throw new IOException(\"Storage not writable: \" + dir);","typeGuard":null,"tryCatchPattern":"try {\n    iconPackManager.removeIconPack(pack);\n} catch (IconPackException e) {\n    Log.w(TAG, \"Delete failed, will retry after releasing handles\", e);\n    // schedule retry or ask user to reboot\n}","preventionTips":["Close streams reading icons before removing a pack","Retrying deletions once after a short delay handles transient locks","Verify storage is mounted writable before removal","Reboot if a directory is persistently undeletable (stale handles)"],"tags":["filesystem","delete","android","io"],"backgroundTag":"directory-delete-failed","analyzedSha":"d6f4e5925a97e4e91593f1542085eae03432a759","analyzedAt":"2026-09-08T00:46:31.111Z","contentChangedAt":"2026-09-08T00:46:31.111Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}