migrate: hustoj: ignore image not exist

This commit is contained in:
undefined committed 2023-08-26 15:22:48 +08:00
1 parent 5403848bc6
commit 7edff0a1ab
1 file changed
+6 -2
+6 -2
View File
@@ -176,8 +176,12 @@ export async function run({
}, 'html');
const uploadFiles = content.matchAll(/(?:src|href)="\/upload\/([^"]+\/([^"]+))"/g);
for (const file of uploadFiles) {
files[file[2]] = await fs.readFile(path.join(uploadDir, file[1]));
content = content.replace(`/upload/${file[1]}`, `file://${file[2]}`);
try {
files[file[2]] = await fs.readFile(path.join(uploadDir, file[1]));
content = content.replace(`/upload/${file[1]}`, `file://${file[2]}`);
} catch (e) {
report({ message: `failed to read file: ${path.join(uploadDir, file[1])}` });
}
}
const pid = await ProblemModel.add(
domainId, `P${pdoc.problem_id}`,