mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
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:
parent
287fa79d75
commit
8747fc4935
1 changed files with 11 additions and 2 deletions
|
|
@ -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 result = firstDateTime(exifTags);
|
||||||
const tag = result?.tag;
|
const tag = result?.tag;
|
||||||
const dateTime = result?.dateTime;
|
const dateTime = result?.dateTime;
|
||||||
|
|
@ -864,7 +868,12 @@ export class MetadataService extends BaseService {
|
||||||
if (!localDateTime || !dateTimeOriginal) {
|
if (!localDateTime || !dateTimeOriginal) {
|
||||||
// FileCreateDate is not available on linux, likely because exiftool hasn't integrated the statx syscall yet
|
// 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
|
// 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(
|
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}`,
|
`No exif date time found, falling back on ${earliestDate.toISOString()}, earliest of file creation and modification for asset ${asset.id}: ${asset.originalPath}`,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue