{"record":{"id":"ba45373799c33a9b","repo":"babalae/better-genshin-impact","slug":"error-ba4537","errorCode":null,"errorMessage":"仓库文件夹不存在，请至少成功更新一次仓库！","messagePattern":"仓库文件夹不存在，请至少成功更新一次仓库！","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"BetterGenshinImpact/Core/Script/WebView/RepoWebBridge.cs","lineNumber":42,"sourceCode":"    private static readonly HashSet<string> AllowedTextExtensions = new(StringComparer.OrdinalIgnoreCase)\n    {\n        \".txt\", \".md\", \".json\", \".js\", \".ts\",\n        \".vue\", \".css\", \".html\", \".csv\", \".xml\",\n        \".yaml\", \".yml\", \".ini\", \".config\"\n    };\n    \n    private static readonly HashSet<string> AllowedImageExtensions = new(StringComparer.OrdinalIgnoreCase)\n    {\n        \".png\", \".jpg\", \".jpeg\", \".gif\", \".webp\", \".svg\", \".bmp\", \".ico\"\n    };\n    \n    public async Task<string> GetRepoJson()\n    {\n        try\n        {\n            if (!Directory.Exists(ScriptRepoUpdater.CenterRepoPath))\n            {\n                throw new InvalidOperationException(\"仓库文件夹不存在，请至少成功更新一次仓库！\");\n            }\n\n            string localRepoJsonPath = GetRepoJsonPath();\n            return await File.ReadAllTextAsync(localRepoJsonPath);\n        }\n        catch (Exception ex)\n        {\n            await ThemedMessageBox.ErrorAsync(ex.Message, \"获取仓库信息失败\");\n            return string.Empty;\n        }\n    }\n\n    public async void ImportUri(string url)\n    {\n        try\n        {\n            await ScriptRepoUpdater.Instance.ImportScriptFromUri(url, false);\n            WeakReferenceMessenger.Default.Send(new RefreshDataMessage(\"Refresh\"));","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/WebView/RepoWebBridge.cs#L24-L60","documentation":"Thrown by RepoWebBridge.GetRepoJson when Directory.Exists(ScriptRepoUpdater.CenterRepoPath) is false. CenterRepoPath is the local clone of the script repository; it only exists after a successful first repo update. The exception is caught immediately and shown via ThemedMessageBox.ErrorAsync, then the method returns string.Empty.","triggerScenarios":"Opening the script-repo WebView before ever clicking 'update repo'; the repo folder was deleted manually; CenterRepoPath points to a non-default location that was never created; first run of the app on a fresh profile.","commonSituations":"New installation with no repo sync yet; user cleared the app data directory; CenterRepoPath misconfigured in settings to a path that does not exist; repo update previously failed silently leaving no folder.","solutions":["Trigger a repository update once (call ScriptRepoUpdater update) so CenterRepoPath is created and populated.","Verify CenterRepoPath exists and is writable before opening the WebView page.","If the path was customized, reset it to the default or recreate the directory and re-run the update.","Check that the prior update did not fail due to network/git errors and retry."],"exampleFix":"// before\nvar json = await bridge.GetRepoJson();\n// after\nif (!Directory.Exists(ScriptRepoUpdater.CenterRepoPath))\n{\n    await ScriptRepoUpdater.Instance.UpdateAsync(ct);\n}\nvar json = await bridge.GetRepoJson();","handlingStrategy":"validation","validationCode":"if (!Directory.Exists(ScriptRepoUpdater.CenterRepoPath))\n{\n    await ScriptRepoUpdater.Instance.UpdateAsync(ct);\n}\nif (!Directory.Exists(ScriptRepoUpdater.CenterRepoPath))\n    return; // still missing after update attempt","typeGuard":null,"tryCatchPattern":"try { var json = await bridge.GetRepoJson(); }\ncatch { /* GetRepoJson already shows ThemedMessageBox and returns \"\" */ }","preventionTips":["Trigger a repo update on first launch before exposing WebView actions.","Disable repo-dependent UI until CenterRepoPath exists.","Verify write permissions and disk space for CenterRepoPath."],"tags":["repo","webview","first-run","filesystem"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}