{"record":{"id":"0db64f486a8062b6","repo":"babalae/better-genshin-impact","slug":"repo-json-0db64f","errorCode":null,"errorMessage":"未找到 repo.json 文件，不是有效的脚本仓库压缩包。","messagePattern":"未找到 repo\\.json 文件，不是有效的脚本仓库压缩包。","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs","lineNumber":1899,"sourceCode":"        string targetFolderName = CenterRepoFolderName;\n\n        try\n        {\n            // 阶段1: 准备 (0-10%)\n            onProgress?.Invoke(0, \"正在准备导入环境...\");\n            DirectoryHelper.DeleteReadOnlyDirectory(ReposTempPath);\n            Directory.CreateDirectory(tempUnzipDir);\n            onProgress?.Invoke(10, \"准备完成，开始解压文件...\");\n\n            // 阶段2: 解压 (10-50%)\n            await Task.Run(() => ZipFile.ExtractToDirectory(zipFilePath, tempUnzipDir, true));\n            onProgress?.Invoke(50, \"文件解压完成，正在验证仓库结构...\");\n\n            // 阶段3: 查找 repo.json (50-55%)\n            var repoJsonPath = Directory.GetFiles(tempUnzipDir, \"repo.json\", SearchOption.AllDirectories).FirstOrDefault();\n            if (repoJsonPath == null)\n            {\n                throw new FileNotFoundException(\"未找到 repo.json 文件，不是有效的脚本仓库压缩包。\");\n            }\n\n            var repoDir = Path.GetDirectoryName(repoJsonPath)!;\n            var newRepoJsonContent = await File.ReadAllTextAsync(repoJsonPath);\n            onProgress?.Invoke(55, \"仓库结构验证通过，正在分析仓库内容...\");\n\n            // 阶段4: 基于目录结构重合度决定目标文件夹 (55-70%)\n            string? bestMatchFolder = null;\n            double bestOverlap = 0;\n\n            // 扫描已有仓库，找目录结构重合度最高的\n            if (Directory.Exists(ReposPath))\n            {\n                foreach (var existingDir in Directory.GetDirectories(ReposPath))\n                {\n                    try\n                    {\n                        var dirName = Path.GetFileName(existingDir);","sourceCodeStart":1881,"sourceCodeEnd":1917,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs#L1881-L1917","documentation":"Thrown by ImportLocalRepoZipCore during zip import: after extracting the user-supplied zip to a temp dir, a recursive search for 'repo.json' found none. The zip is rejected as not a valid script repository package.","triggerScenarios":"ImportLocalRepoZipCore extracts zipFilePath with ZipFile.ExtractToDirectory, then Directory.GetFiles(tempUnzipDir, \"repo.json\", SearchOption.AllDirectories).FirstOrDefault() returns null.","commonSituations":"User selected a zip that isn't a script repo (wrong file); the zip is a valid archive but the manifest was named differently or nested in a way the search should catch but didn't (e.g., the zip has a top-level folder and repo.json is inside — this should still be found by AllDirectories, so most likely the file is genuinely absent); the zip was corrupted and extraction silently dropped files.","solutions":["Confirm the selected zip actually contains a repo.json: open it and inspect the contents before importing.","If extraction may have been partial, verify the extracted file count matches the zip's entry count before searching.","Re-export/re-download the script repo zip from a trusted source.","Surface the temp extraction dir path in the error so the user/dev can inspect what was actually extracted."],"exampleFix":"// before\nvar repoJsonPath = Directory.GetFiles(tempUnzipDir, \"repo.json\", SearchOption.AllDirectories).FirstOrDefault();\nif (repoJsonPath == null)\n    throw new FileNotFoundException(\"未找到 repo.json 文件，不是有效的脚本仓库压缩包。\");\n\n// after (include what was found)\nvar repoJsonPath = Directory.GetFiles(tempUnzipDir, \"repo.json\", SearchOption.AllDirectories).FirstOrDefault();\nif (repoJsonPath == null)\n{\n    var extracted = Directory.GetFiles(tempUnzipDir, \"*\", SearchOption.AllDirectories);\n    throw new FileNotFoundException(\n        $\"未找到 repo.json 文件，不是有效的脚本仓库压缩包。解压目录 {tempUnzipDir} 共 {extracted.Length} 个文件。\",\n        Path.Combine(tempUnzipDir, \"repo.json\"));\n}","handlingStrategy":"validation","validationCode":"// Verify the zip contains repo.json before extracting\nusing var archive = ZipFile.OpenRead(zipFilePath);\nbool hasRepoJson = archive.Entries.Any(e => e.Name == \"repo.json\");\nif (!hasRepoJson)\n    throw new ArgumentException(\"所选压缩包不含 repo.json，不是脚本仓库\");","typeGuard":null,"tryCatchPattern":"catch (FileNotFoundException ex) when (ex.Message.Contains(\"repo.json\"))\n{\n    Toast.Error(\"压缩包无效：缺少 repo.json，请选择正确的脚本仓库压缩包。\");\n}","preventionTips":["Inspect the zip's entry list before extracting to fail fast.","Confirm the zip came from a trusted script-repo source.","Show the extracted file count in the error for diagnosis."],"tags":["zip","filesystem","import","manifest","repo-json"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}