Prevent storing invalid images

This commit is contained in:
Matt Isenhower
2024-11-18 20:33:33 -08:00
parent 34c2d65b15
commit 0fe794007e

View File

@@ -66,6 +66,10 @@ export default class ImageProcessor
try {
let result = await fetch(url);
if (!result.ok) {
throw new Error(`Invalid image response code: ${result.status}`);
}
await mkdirp(path.dirname(this.localPath(destination)));
await fs.writeFile(this.localPath(destination), result.body);
} catch (e) {