{"record":{"id":"af11f386a1f87493","repo":"MuntashirAkon/AppManager","slug":"could-not-finalise-backup-sbconverter","errorCode":null,"errorMessage":"Could not finalise backup.","messagePattern":"Could not finalise backup\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java","lineNumber":147,"sourceCode":"                Map<String, String> filenameChecksumMap = MetadataManager.writeMetadata(mDestMetadata, mBackupItem);\n                for (Map.Entry<String, String> filenameChecksumPair : filenameChecksumMap.entrySet()) {\n                    mChecksum.add(filenameChecksumPair.getKey(), filenameChecksumPair.getValue());\n                }\n            } catch (IOException e) {\n                throw new BackupException(\"Failed to write metadata.\");\n            }\n            mChecksum.close();\n            // Encrypt checksum\n            try {\n                mBackupItem.encrypt(new Path[]{mChecksum.getFile()});\n            } catch (IOException e) {\n                throw new BackupException(\"Failed to encrypt checksums.txt\");\n            }\n            // Replace current backup\n            try {\n                mBackupItem.commit();\n            } catch (IOException e) {\n                throw new BackupException(\"Could not finalise backup.\", e);\n            }\n            backupSuccess = true;\n        } catch (BackupException e) {\n            throw e;\n        } catch (Throwable th) {\n            throw new BackupException(\"Unknown error occurred.\", th);\n        } finally {\n            mBackupItem.cleanup();\n            mCachedApk.requireParent().delete();\n            if (backupSuccess) {\n                BackupUtils.putBackupToDbAndBroadcast(ContextUtils.getContext(), mDestMetadata);\n            }\n        }\n    }\n\n    @Override\n    public void cleanup() {\n        for (Path file : mFilesToBeDeleted) {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java#L129-L165","documentation":"SBConverter.convert throws BackupException('Could not finalise backup.') when mBackupItem.commit() throws IOException. Commit atomically replaces the staging backup with the final backup; failure here means the backup files exist but were not promoted, so conversion reports failure.","triggerScenarios":"commit() fails renaming/moving staged backup files into place: destination directory conflicts, cross-filesystem moves, unwritable target, or I/O errors during the move.","commonSituations":"Existing backup with the same name blocking the commit; storage full; Android file APIs failing across mount points; stale staging directories.","solutions":["Delete any pre-existing/conflicting backup with the same name and retry","Check free space and writability of the final backup location","Inspect the wrapped IOException cause for the exact move/rename error","Retry conversion; leftover staging is cleaned up in the finally block"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure no conflicting final backup exists before commit\nFile finalDir = new File(BackupUtils.getBackupPath(mUserId, mPackageName, mDestMetadata.backupName));\nif (finalDir.exists()) {\n    throw new IOException(\"Conflicting backup already exists at \" + finalDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    converter.convert(...);\n} catch (BackupException e) {\n    if (\"Could not finalise backup.\".equals(e.getMessage())) {\n        // staging was cleaned up; resolve conflict/free space and retry conversion\n    }\n}","preventionTips":["Remove backups with conflicting names before conversion","Keep staging and final backups on the same filesystem","Maintain free space headroom on the destination volume"],"tags":["android","backup","commit","io"],"backgroundTag":"file-write-failed","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}