mirror of
https://github.com/immich-app/immich.git
synced 2026-02-28 09:38:43 +03:00
fix: prevent server crash when extraction of metadata fails if the assets are corrupted (#26042)
* Fix-25968 Extraction of metadata fails if the assets are corrupted * chore: clean up --------- Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
@@ -38,6 +38,9 @@ import { isFaceImportEnabled } from 'src/utils/misc';
|
|||||||
import { upsertTags } from 'src/utils/tag';
|
import { upsertTags } from 'src/utils/tag';
|
||||||
import { Tasks } from 'src/utils/tasks';
|
import { Tasks } from 'src/utils/tasks';
|
||||||
|
|
||||||
|
const POSTGRES_INT_MAX = 2_147_483_647;
|
||||||
|
const POSTGRES_INT_MIN = -2_147_483_648;
|
||||||
|
|
||||||
/** look for a date from these tags (in order) */
|
/** look for a date from these tags (in order) */
|
||||||
const EXIF_DATE_TAGS: Array<keyof ImmichTags> = [
|
const EXIF_DATE_TAGS: Array<keyof ImmichTags> = [
|
||||||
'SubSecDateTimeOriginal',
|
'SubSecDateTimeOriginal',
|
||||||
@@ -90,7 +93,10 @@ const validate = <T>(value: T): NonNullable<T> | null => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === 'number' && (Number.isNaN(value) || !Number.isFinite(value))) {
|
if (
|
||||||
|
typeof value === 'number' &&
|
||||||
|
(Number.isNaN(value) || !Number.isFinite(value) || value < POSTGRES_INT_MIN || value > POSTGRES_INT_MAX)
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user