Skip to content

Commit 8747fc4

Browse files
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 <[email protected]>
1 parent 287fa79 commit 8747fc4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

server/src/services/metadata.service.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,11 @@ export class MetadataService extends BaseService {
835835
}
836836
}
837837

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

0 commit comments

Comments
 (0)