chore: ensure mirror file list consistency after upload

This commit is contained in:
daydreamer-json
2026-02-16 11:24:08 +09:00
parent 43900d5509
commit 3cca106f88

View File

@@ -158,10 +158,8 @@ async function saveResult<T>(
}
async function saveToGHMirror(url: string, name: string | null): Promise<void> {
const mirrorFileDb = await (async () => {
const localJsonPath = path.join(argvUtils.getArgv()['outputDir'], 'mirror_file_list.json');
return (await Bun.file(localJsonPath).json()) as MirrorFileEntry[];
})();
const mirrorFileDb = (await Bun.file(localJsonPath).json()) as MirrorFileEntry[];
if (!mirrorFileDb.find((e) => e.orig.includes(stringUtils.removeQueryStr(url)))) {
await githubUtils.uploadAsset(octoClient, githubAuthCfg, url, name);
if (githubAuthCfg) {
@@ -169,6 +167,7 @@ async function saveToGHMirror(url: string, name: string | null): Promise<void> {
orig: stringUtils.removeQueryStr(url),
mirror: `https://github.com/${githubAuthCfg.owner}/${githubAuthCfg.repo}/releases/download/${githubAuthCfg.tag}/${name ?? new URL(url).pathname.split('/').pop() ?? ''}`,
});
await Bun.write(localJsonPath, JSON.stringify(mirrorFileDb));
}
}
}