{"record":{"id":"ae9ba4965e369121","repo":"beemdevelopment/Aegis","slug":"unable-to-create-directory-s","errorCode":null,"errorMessage":"Unable to create directory %s","messagePattern":"Unable to create directory (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/beemdevelopment/aegis/ui/fragments/preferences/ImportExportPreferencesFragment.java","lineNumber":436,"sourceCode":"            return new VaultBackupManager.FileInfo(VaultRepository.FILENAME_PREFIX_EXPORT_HTML, \"html\");\n        }\n\n        return new VaultBackupManager.FileInfo(VaultRepository.FILENAME_PREFIX_EXPORT_URI, \"txt\");\n    }\n\n    private static String getExportMimeType(int requestCode) {\n        if (requestCode == CODE_EXPORT_GOOGLE_URI) {\n            return \"text/plain\";\n        } else if (requestCode == CODE_EXPORT_HTML) {\n            return \"text/html\";\n        }\n        return \"application/json\";\n    }\n\n    private File getExportCacheDir() throws IOException {\n        File dir = new File(requireContext().getCacheDir(), \"export\");\n        if (!dir.exists() && !dir.mkdir()) {\n            throw new IOException(String.format(\"Unable to create directory %s\", dir));\n        }\n\n        return dir;\n    }\n\n    private void startExportVault(int requestCode, StartExportCallback cb, @Nullable Vault.EntryFilter filter) {\n        switch (requestCode) {\n            case CODE_EXPORT:\n                if (_vaultManager.getVault().isEncryptionEnabled()) {\n                    cb.exportVault(stream -> {\n                        if (filter != null) {\n                            _vaultManager.getVault().exportFiltered(stream, filter);\n                        } else {\n                            _vaultManager.getVault().export(stream);\n                        }\n                    });\n                } else {\n                    Dialogs.showSetPasswordDialog(requireActivity(), new Dialogs.PasswordSlotListener() {","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/beemdevelopment/Aegis/blob/d6f4e5925a97e4e91593f1542085eae03432a759/app/src/main/java/com/beemdevelopment/aegis/ui/fragments/preferences/ImportExportPreferencesFragment.java#L418-L454","documentation":"ImportExportPreferencesFragment.getExportCacheDir() creates a 'export' subdirectory inside the app cache dir before writing an export file. If the directory does not exist and File.mkdir() fails (returns false), it throws an IOException with the directory path. Called by startExport and onExportResult when preparing vault exports.","triggerScenarios":"Invoking startExport/onExportResult on a device where cache dir creation fails — typically storage full, the cache path exists as a file, or a transient filesystem/permission problem prevents mkdir().","commonSituations":"Devices with full internal storage, corrupted cache directories, restricted app storage after OEM 'cleaner' apps interfering, or concurrent export attempts racing on the same path.","solutions":["Free up device storage and retry the export","Clear the app's cache (Settings > Apps > Aegis > Storage > Clear cache) and retry","Reboot the device to release file locks, then retry the export","If it persists, reinstall the app (after backing up the vault) to reset the cache directory state"],"exampleFix":"// before\nif (!dir.exists() && !dir.mkdir()) {\n    throw new IOException(String.format(\"Unable to create directory %s\", dir));\n}\n// after\nif (!dir.exists() && !dir.mkdirs()) {\n    throw new IOException(String.format(\"Unable to create directory %s\", dir));\n}","handlingStrategy":"try-catch","validationCode":"File dir = new File(requireContext().getCacheDir(), \"export\");\nif (!dir.exists() && !dir.isDirectory() && requireContext().getCacheDir().getUsableSpace() < requiredBytes) {\n    // prompt user to free storage before exporting\n}","typeGuard":null,"tryCatchPattern":"try {\n    startExport(requestCode, cb, filter);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to create directory\")) {\n        // show storage-full/clear-cache guidance to the user\n    }\n}","preventionTips":["Check getUsableSpace() on the cache dir before exporting","Pre-create the export directory lazily and clean it up after each export","Handle mkdir failure with mkdirs() and a retry before failing","Avoid concurrent export operations racing on the same cache path"],"tags":["android","filesystem","io","export","storage"],"backgroundTag":"mkdir-permission-denied","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"}