babalae/better-genshin-impact · warning · FileNotFoundException
找不到原始 repo.json 文件
Error message
找不到原始 repo.json 文件
What it means
Thrown by RepoWebBridge.ClearUpdate when a recursive Directory.GetFiles(CenterRepoPath, 'repo.json', AllDirectories) returns no match. ClearUpdate copies the pristine repo.json over RepoUpdatedJsonPath to wipe local 'hasUpdate' edits. The FileNotFoundException is caught and shown as '清空更新标记失败'.
Source
Thrown at BetterGenshinImpact/Core/Script/WebView/RepoWebBridge.cs:205
}
catch (Exception ex)
{
await ThemedMessageBox.ErrorAsync(ex.Message, "信息更新失败");
return false;
}
}
public async Task<bool> ClearUpdate()
{
try
{
string? repoJsonPath = Directory
.GetFiles(ScriptRepoUpdater.CenterRepoPath, "repo.json", SearchOption.AllDirectories)
.FirstOrDefault();
if (string.IsNullOrEmpty(repoJsonPath))
{
throw new FileNotFoundException("找不到原始 repo.json 文件");
}
string targetPath = ScriptRepoUpdater.RepoUpdatedJsonPath;
File.Copy(repoJsonPath, targetPath, overwrite: true);
return true;
}
catch (Exception ex)
{
await ThemedMessageBox.ErrorAsync($"清空更新标记失败: {ex.Message}", "操作失败");
return false;
}
}
// 设置新手引导标志位
public bool SetGuideStatus(bool status)
{View on GitHub (pinned to a7cb36712d)
Solutions
- Re-run the repository update to restore repo.json under CenterRepoPath.
- Validate the repo folder layout (expect .../repo/repo.json) and report if the structure differs.
- If repo.json lives elsewhere, update ClearUpdate's search pattern or the repo manifest.
- Delete CenterRepoPath and re-clone from scratch to eliminate corruption.
Defensive patterns
Strategy: validation
Validate before calling
bool HasRepoJson() => Directory.Exists(ScriptRepoUpdater.CenterRepoPath) &&
Directory.GetFiles(ScriptRepoUpdater.CenterRepoPath, "repo.json", SearchOption.AllDirectories).Length > 0; Prevention
- Validate repo.json presence before offering ClearUpdate.
- Re-clone if the file is missing after an update.
- Check repo folder integrity after updates.
When it happens
Trigger: CenterRepoPath exists but the inner 'repo' subfolder (or the repo.json inside it) is missing — e.g. a partial/empty clone, a corrupted extraction, or the repo layout changed and repo.json moved. Distinct from 142/143 because the folder exists but the index file does not.
Common situations: Repo update was interrupted leaving an empty directory; user deleted repo.json manually; git clone succeeded but checkout left only metadata; repo schema migration removed the file.
Related errors
- 仓库文件夹不存在,请至少成功更新一次仓库!
- repo.json 仓库索引文件不存在,请至少成功更新一次仓库!
- 文件 '{relativePath}' 不存在
- 读取文件失败: {ex.Message}
- 写入文件失败: {ex.Message}
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/dc316ecfcd750031.
Report an issue: GitHub.