fix(gallery): filter out files without exif data
Some checks failed
Build and Push Docker Image / build (push) Failing after 1m48s
Some checks failed
Build and Push Docker Image / build (push) Failing after 1m48s
This commit is contained in:
@@ -29,7 +29,8 @@ export default defineCachedEventHandler(
|
||||
/\.(jpg|jpeg|png|webp)$/i.test(file),
|
||||
);
|
||||
|
||||
const imagesWithExif = await Promise.all(
|
||||
const imagesWithExif = (
|
||||
await Promise.all(
|
||||
imageFiles.map(async (filename) => {
|
||||
const filePath = join(galleryDir, filename);
|
||||
const rawExif = await exifr.parse(filePath, {
|
||||
@@ -40,7 +41,10 @@ export default defineCachedEventHandler(
|
||||
ifd1: false,
|
||||
});
|
||||
|
||||
const exif = exifSchema.parse(rawExif);
|
||||
if (!rawExif) return null;
|
||||
const parsed = exifSchema.safeParse(rawExif);
|
||||
if (!parsed.success) return null;
|
||||
const exif = parsed.data;
|
||||
|
||||
return {
|
||||
filename,
|
||||
@@ -60,7 +64,8 @@ export default defineCachedEventHandler(
|
||||
},
|
||||
};
|
||||
}),
|
||||
);
|
||||
)
|
||||
).filter((img) => img !== null);
|
||||
|
||||
return imagesWithExif;
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user