{"record":{"id":"adcb6b4469e1423f","repo":"MuntashirAkon/AppManager","slug":"data-restore-is-requested-but-there-are-no-data-files-for-adcb6b","errorCode":null,"errorMessage":"Data restore is requested but there are no data files for index ${index}.","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":527,"sourceCode":"            String backupDataDir = mBackupMetadata.dataDirs[i];\n            if (backupDataDir.equals(BackupManager.DATA_BACKUP_SPECIAL_ADB)) {\n                // Adb backup restore\n                restoreAdb(i);\n            } else {\n                // Regular directory restore\n                restoreDirectory(mBackupMetadata.dataDirs[i], i);\n            }\n        }\n    }\n\n    private void restoreDirectory(@NonNull String dir, int index) throws BackupException {\n        String dataSource = BackupUtils.getWritableDataDirectory(dir, mBackupInfo.userId, mUserId);\n        BackupDataDirectoryInfo dataDirectoryInfo = BackupDataDirectoryInfo.getInfo(dataSource, mUserId);\n        Path dataSourceFile = dataDirectoryInfo.getDirectory();\n\n        Path[] dataFiles = mBackupItem.getDataFiles(index);\n        if (dataFiles.length == 0) {\n            throw new BackupException(\"Data restore is requested but there are no data files for index \" + index + \".\");\n        }\n        UidGidPair uidGidPair = dataSourceFile.getUidGid();\n        if (uidGidPair == null) {\n            // Fallback to app UID\n            uidGidPair = new UidGidPair(mUid, mUid);\n        }\n        if (dataDirectoryInfo.isExternal()) {\n            // Skip if external data restore is not requested\n            switch (dataDirectoryInfo.subtype) {\n                case BackupDataDirectoryInfo.TYPE_ANDROID_DATA:\n                    // Skip restoring Android/data directory if not requested\n                    if (!mRequestedFlags.backupExternalData()) {\n                        return;\n                    }\n                    break;\n                case BackupDataDirectoryInfo.TYPE_ANDROID_OBB:\n                case BackupDataDirectoryInfo.TYPE_ANDROID_MEDIA:\n                    // Skip restoring Android/data or Android/media if media/obb restore not requested","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L509-L545","documentation":"restoreDirectory, invoked per data directory, requires the list of backup archive files for that index. If mBackupItem.getDataFiles(index) is empty, it throws this BackupException before touching the target directory. Unlike error 133 (raised during checksum verification), this fires even when signature checks are skipped.","triggerScenarios":"Data archive files for the given index missing from the backup directory; index refers to a data dir whose files were deleted; restoring with skipSignatureCheck enabled so the earlier check (error 133) never ran; misnamed data files so getDataFiles finds none.","commonSituations":"Manual pruning of large .tar files to save space; interrupted backup that never wrote the archives; user renamed files breaking the expected naming pattern.","solutions":["Restore the missing data archive files for that index from the original backup source.","Re-create the backup, ensuring it completes without interruption.","Check file naming matches what BackupFiles.BackupItem.getDataFiles() expects (don't rename backup files).","Remove the corresponding dataDirs entry from metadata if that data directory is intentionally absent."],"exampleFix":"// before: restoring pruned backup\new RestoreOp(...).runRestore(); // throws: no data files for index\n// after: check per-index availability before restoring\nif (backupItem.getDataFiles(0).length == 0) {\n    restoreApkOnly(); // fall back instead of failing\n} else {\n    runRestore();\n}","handlingStrategy":"validation","validationCode":"int index = 0; // per directory\nif (backupItem.getDataFiles(index).length == 0)\n    throw new IllegalStateException(\"Missing data archives for index \" + index);\n","typeGuard":"boolean indexPresent(BackupItem item, int index) { return item.getDataFiles(index).length > 0; }","tryCatchPattern":"try { runRestore(); } catch (BackupException e) {\n    if (e.getMessage().contains(\"no data files for index\")) {\n        // fall back to app-only restore\n        restoreWithoutData();\n    } else throw e;\n}","preventionTips":["Keep the backup directory intact — never prune data .tar files selectively.","Let backups finish; don't kill App Manager mid-backup.","Don't rename backup archives; discovery relies on naming.","Audit backup completeness before deleting the source installation."],"tags":["android","backup","restore","missing-files"],"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"}