mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
migrate: hustoj: ignore image not exist
This commit is contained in:
1 file changed
+4
@@ -176,8 +176,12 @@ export async function run({
|
|||||||
}, 'html');
|
}, 'html');
|
||||||
const uploadFiles = content.matchAll(/(?:src|href)="\/upload\/([^"]+\/([^"]+))"/g);
|
const uploadFiles = content.matchAll(/(?:src|href)="\/upload\/([^"]+\/([^"]+))"/g);
|
||||||
for (const file of uploadFiles) {
|
for (const file of uploadFiles) {
|
||||||
|
try {
|
||||||
files[file[2]] = await fs.readFile(path.join(uploadDir, file[1]));
|
files[file[2]] = await fs.readFile(path.join(uploadDir, file[1]));
|
||||||
content = content.replace(`/upload/${file[1]}`, `file://${file[2]}`);
|
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(
|
const pid = await ProblemModel.add(
|
||||||
domainId, `P${pdoc.problem_id}`,
|
domainId, `P${pdoc.problem_id}`,
|
||||||
|
|||||||
Reference in new issue
Block a user