fix(server): consider asset creation date when EXIF is missing (#21586)

* fix(server): fallback to asset.fileCreatedAt when EXIF is missing

* merge main

---------

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Riccardo Ruspoli 2025-09-04 21:18:12 +02:00 committed by GitHub
parent 287fa79d75
commit 8747fc4935
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -835,7 +835,11 @@ export class MetadataService extends BaseService {
}
}
private getDates(asset: { id: string; originalPath: string }, exifTags: ImmichTags, stats: Stats) {
private getDates(
asset: { id: string; originalPath: string; fileCreatedAt: Date },
exifTags: ImmichTags,
stats: Stats,
) {
const result = firstDateTime(exifTags);
const tag = result?.tag;
const dateTime = result?.dateTime;
@ -864,7 +868,12 @@ export class MetadataService extends BaseService {
if (!localDateTime || !dateTimeOriginal) {
// FileCreateDate is not available on linux, likely because exiftool hasn't integrated the statx syscall yet
// birthtime is not available in Docker on macOS, so it appears as 0
const earliestDate = stats.birthtimeMs ? new Date(Math.min(stats.mtimeMs, stats.birthtimeMs)) : stats.mtime;
const earliestDate = new Date(
Math.min(
asset.fileCreatedAt.getTime(),
stats.birthtimeMs ? Math.min(stats.mtimeMs, stats.birthtimeMs) : stats.mtime.getTime(),
),
);
this.logger.debug(
`No exif date time found, falling back on ${earliestDate.toISOString()}, earliest of file creation and modification for asset ${asset.id}: ${asset.originalPath}`,
);