{"record":{"id":"f71f686cec190376","repo":"MuntashirAkon/AppManager","slug":"backup-failed-for-sbconverter","errorCode":null,"errorMessage":"Backup failed for ","messagePattern":"Backup failed for ","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java","lineNumber":264,"sourceCode":"                        if (tmpFile != null) {\n                            // Copy from the temporary file\n                            try (FileInputStream fis = new FileInputStream(tmpFile)) {\n                                IoUtils.copy(fis, tos);\n                            } finally {\n                                FileCache.getGlobalFileCache().delete(tmpFile);\n                            }\n                        }\n                        tos.closeArchiveEntry();\n                    }\n                    tos.finish();\n                }\n                // Encrypt backups\n                Path[] newBackupFiles = mBackupItem.encrypt(sos.getFiles().toArray(new Path[0]));\n                for (Path file : newBackupFiles) {\n                    mChecksum.add(file.getName(), DigestUtils.getHexDigest(mDestMetadata.info.checksumAlgo, file));\n                }\n            } catch (IOException e) {\n                throw new BackupException(\"Backup failed for \" + dataFile, e);\n            }\n        }\n    }\n\n    @SuppressLint(\"WrongConstant\")\n    @NonNull\n    private BackupMetadataV2 generateMetadata() throws BackupException {\n        BackupMetadataV2 metadataV2 = new BackupMetadataV2();\n        mCachedApk = FileUtils.getTempPath(mPackageName, \"base.apk\");\n        try (InputStream pis = getApkFile().openInputStream()) {\n            try (OutputStream fos = mCachedApk.openOutputStream()) {\n                IoUtils.copy(pis, fos);\n            }\n            mFilesToBeDeleted.add(getApkFile());\n        } catch (IOException e) {\n            throw new BackupException(\"Could not cache APK file\", e);\n        }\n        String filePath = Objects.requireNonNull(mCachedApk.getFilePath());","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java#L246-L282","documentation":"Thrown by SBConverter.backupData when any IOException occurs while re-tarring a source data zip into the destination backup: reading the ZipInputStream, writing the split tar output, or encrypting the produced files. The offending data file is named in the message.","triggerScenarios":"Corrupt or non-zip data archive (ZipInputStream returns garbage/unexpected EOF), disk full in the destination split output, destination not writable, or encrypt() failing inside the same try-with-resources block.","commonSituations":"Interrupted downloads/copies leaving truncated data zips; converting large app data archives onto full storage; SD-card/USB backup destinations being unmounted mid-conversion; zip format changes in newer Swift Backup versions the converter can't parse.","solutions":["Test the named data file with a zip utility; re-export the source archive if it is corrupt.","Free up disk space or choose a destination with enough room for the uncompressed plus encrypted copies.","Check write permissions on the destination path (especially external storage on Android 11+).","Retry after confirming stable storage; transient I/O errors can abort the whole per-file loop."],"exampleFix":"// before: assume zip is valid\nzis.getNextEntry(); // IOException -> 'Backup failed for'\n// after: validate archive first\ntry (ZipFile zf = new ZipFile(dataFile.getFilePath())) {\n    if (zf.size() == 0) throw new IOException(\"empty archive\");\n}\n// then proceed with conversion","handlingStrategy":"try-catch","validationCode":"// validate the data archive is a readable zip before conversion\ntry (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(\n        new FileInputStream(dataZip)))) {\n    if (zis.getNextEntry() == null)\n        throw new IOException(\"empty or corrupt zip: \" + dataZip);\n}","typeGuard":null,"tryCatchPattern":"try { converter.convert(); }\ncatch (BackupException e) {\n    if (e.getMessage().startsWith(\"Backup failed for\")) {\n        Path bad = Path.of(e.getMessage().substring(\"Backup failed for \".length()));\n        // validate/re-acquire bad file before retrying\n    }\n}","preventionTips":["Verify source zips with a zip tool before converting","Keep 2x the archive size free in the destination","Avoid unmounting external storage mid-conversion","Retry conversions on stable power and storage"],"tags":["android","backup","zip","tar","io"],"backgroundTag":"file-read-failed","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}