Catch IPTC and XMP extraction errors (#17633)

* Catch IPTC and XMP extraction errors

* Add autoPurgeCache option to uploadOne

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>

---------

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
This commit is contained in:
ian
2023-02-27 19:05:00 +08:00
committed by GitHub
parent 9856019c3a
commit fb41eee1ed

View File

@@ -103,7 +103,7 @@ export class FilesService extends ItemsService {
await sudoService.updateOne(primaryKey, payload, { emitEvents: false });
if (this.cache && env.CACHE_AUTO_PURGE) {
if (this.cache && env.CACHE_AUTO_PURGE && opts?.autoPurgeCache !== false) {
await this.cache.clear();
}
@@ -187,10 +187,20 @@ export class FilesService extends ItemsService {
}
}
if (sharpMetadata.iptc) {
fullMetadata.iptc = parseIptc(sharpMetadata.iptc);
try {
fullMetadata.iptc = parseIptc(sharpMetadata.iptc);
} catch (err) {
logger.warn(`Couldn't extract IPTC Photo Metadata from file`);
logger.warn(err);
}
}
if (sharpMetadata.xmp) {
fullMetadata.xmp = parseXmp(sharpMetadata.xmp);
try {
fullMetadata.xmp = parseXmp(sharpMetadata.xmp);
} catch (err) {
logger.warn(`Couldn't extract XMP data from file`);
logger.warn(err);
}
}
if (fullMetadata?.iptc?.Caption && typeof fullMetadata.iptc.Caption === 'string') {