mirror of
https://github.com/daydreamer-json/ak-endfield-api-archive.git
synced 2026-03-21 23:02:20 +01:00
chore: ensure mirror file list consistency after upload
This commit is contained in:
@@ -158,10 +158,8 @@ async function saveResult<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function saveToGHMirror(url: string, name: string | null): Promise<void> {
|
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');
|
||||||
const localJsonPath = path.join(argvUtils.getArgv()['outputDir'], 'mirror_file_list.json');
|
const mirrorFileDb = (await Bun.file(localJsonPath).json()) as MirrorFileEntry[];
|
||||||
return (await Bun.file(localJsonPath).json()) as MirrorFileEntry[];
|
|
||||||
})();
|
|
||||||
if (!mirrorFileDb.find((e) => e.orig.includes(stringUtils.removeQueryStr(url)))) {
|
if (!mirrorFileDb.find((e) => e.orig.includes(stringUtils.removeQueryStr(url)))) {
|
||||||
await githubUtils.uploadAsset(octoClient, githubAuthCfg, url, name);
|
await githubUtils.uploadAsset(octoClient, githubAuthCfg, url, name);
|
||||||
if (githubAuthCfg) {
|
if (githubAuthCfg) {
|
||||||
@@ -169,6 +167,7 @@ async function saveToGHMirror(url: string, name: string | null): Promise<void> {
|
|||||||
orig: stringUtils.removeQueryStr(url),
|
orig: stringUtils.removeQueryStr(url),
|
||||||
mirror: `https://github.com/${githubAuthCfg.owner}/${githubAuthCfg.repo}/releases/download/${githubAuthCfg.tag}/${name ?? new URL(url).pathname.split('/').pop() ?? ''}`,
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user