{"record":{"id":"1c2a3631489f941d","repo":"MuntashirAkon/AppManager","slug":"data-restore-is-requested-but-there-are-no-data-files-for","errorCode":null,"errorMessage":"Data restore is requested but there are no data files for index ${i}.","messagePattern":"Data restore is requested but there are no data files for index (.+?)\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":492,"sourceCode":"                throw new BackupException(\"Failed to rename KeyStore files\", e);\n            }\n        }\n        Runner.runCommand(new String[]{\"restorecon\", \"-R\", keyStorePath.getFilePath()});\n    }\n\n    private void restoreData() throws BackupException {\n        // Data restore is requested: Data restore is only possible if the app is actually\n        // installed. So, check if it's installed first.\n        if (mPackageInfo == null) {\n            throw new BackupException(\"Data restore is requested but the app isn't installed.\");\n        }\n        if (!mRequestedFlags.skipSignatureCheck()) {\n            // Verify integrity of the data backups\n            String checksum;\n            for (int i = 0; i < mBackupMetadata.dataDirs.length; ++i) {\n                Path[] dataFiles = mBackupItem.getDataFiles(i);\n                if (dataFiles.length == 0) {\n                    throw new BackupException(\"Data restore is requested but there are no data files for index \" + i + \".\");\n                }\n                for (Path file : dataFiles) {\n                    checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, file);\n                    if (!checksum.equals(mChecksum.get(file.getName()))) {\n                        throw new BackupException(\"Data file verification failed for index \" + i + \".\" +\n                                \"\\nFile: \" + file +\n                                \"\\nFound: \" + checksum +\n                                \"\\nRequired: \" + mChecksum.get(file.getName()));\n                    }\n                }\n            }\n        }\n        // Force-stop and clear app data\n        PackageManagerCompat.clearApplicationUserData(mPackageName, mUserId);\n        // Restore backups\n        for (int i = 0; i < mBackupMetadata.dataDirs.length; ++i) {\n            String backupDataDir = mBackupMetadata.dataDirs[i];\n            if (backupDataDir.equals(BackupManager.DATA_BACKUP_SPECIAL_ADB)) {","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L474-L510","documentation":"During signature/integrity verification in restoreData, if BackupFiles.BackupItem.getDataFiles(i) returns an empty array for any data directory index, this BackupException is thrown. It means the backup metadata claims a data directory exists (mBackupMetadata.dataDirs.length entries) but no corresponding backup files (tar, etc.) were found on disk.","triggerScenarios":"The backup directory is missing its data .tar/.tar.gz files for index i while metadata lists that data dir; files were deleted/moved manually; metadata (meta files) edited to add a dataDir without backing files; external-storage data backup located on an unmounted SD card.","commonSituations":"Partial backup (process killed mid-backup) leaving metadata but no data archives; user copied only some files when moving backups between devices; data files stored on removable storage that isn't mounted.","solutions":["Re-create the backup; the existing one is incomplete and cannot pass verification.","Copy the missing data backup files for index i into the backup directory.","Check that external storage (SD card) containing the data backup is mounted.","If the data dir was intentionally skipped, re-create metadata without that dataDirs entry or skip signature check (skipSignatureCheck) — not recommended."],"exampleFix":"// before: restoring from a partial backup\new BackupManager(...).runRestore(); // throws for missing index files\n// after: validate backup completeness first\nfor (int i = 0; i < metadata.dataDirs.length; i++) {\n    if (backupItem.getDataFiles(i).length == 0) {\n        throw new IllegalStateException(\"Backup incomplete: missing data files for index \" + i);\n    }\n}\nrunRestore();","handlingStrategy":"validation","validationCode":"for (int i = 0; i < metadata.dataDirs.length; i++) {\n    if (backupItem.getDataFiles(i).length == 0)\n        throw new IllegalStateException(\"Incomplete backup: no data files for index \" + i);\n}\n","typeGuard":"boolean hasAllDataFiles(BackupItem item, int dirCount) {\n    for (int i = 0; i < dirCount; i++) if (item.getDataFiles(i).length == 0) return false;\n    return true;\n}","tryCatchPattern":"try { runRestore(); } catch (BackupException e) {\n    if (e.getMessage().startsWith(\"Data restore is requested but there are no data files\")) {\n        promptUserForCompleteBackup();\n    } else throw e;\n}","preventionTips":["Don't move backups by copying a subset of files — copy the whole backup directory.","Verify backups complete without interruption (check final checksums file).","Mount external storage holding data archives before restoring.","Match metadata and archives: never hand-edit backup metadata."],"tags":["android","backup","restore","missing-files","integrity-check"],"backgroundTag":"file-not-found","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"}