beemdevelopment/Aegis · error · IOException

Unable to delete directory

Error message

Unable to delete directory: %s

What it means

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.

Solutions

  1. Retry the icon pack removal after closing other Aegis screens/background work
  2. Reboot the device to release file handles, then remove the pack again
  3. Check the storage is writable; remount external storage if read-only
  4. Manually clear Aegis's data/cache if the directory remains stuck
Defensive patterns

Strategy: retry

Validate before calling

File dir = getIconPackDir(pack);
if (!dir.exists()) return; // nothing to delete
if (!dir.canWrite()) throw new IOException("Storage not writable: " + dir);

Try / catch

try {
    iconPackManager.removeIconPack(pack);
} catch (IconPackException e) {
    Log.w(TAG, "Delete failed, will retry after releasing handles", e);
    // schedule retry or ask user to reboot
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of beemdevelopment/Aegis@d6f4e5925a (2026-09-08). Data as JSON: /api/errors/d4ea7cec3cc7f415. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/com/beemdevelopment/aegis/icons/IconPackManager.java:223

        if (latestVersion == -1) {
            return null;
        }

        return new File(packDir, Integer.toString(latestVersion));
    }

    private static void deleteDir(File dir) throws IOException {
        if (dir.isDirectory()) {
            File[] children = dir.listFiles();
            if (children != null) {
                for (File child : children) {
                    deleteDir(child);
                }
            }
        }

        if (!dir.delete()) {
            throw new IOException(String.format("Unable to delete directory: %s", dir));
        }
    }
}

View on GitHub (pinned to d6f4e5925a)