-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(server): use the earliest date between file creation and modification timestamps when missing exif tags #14874
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please address the comments
📖 Documentation deployed to pr-14874.preview.immich.app |
this.logger.warn( | ||
`No valid date found in exif tags from asset ${asset.id}, falling back to earliest timestamp between file creation and file modification`, | ||
); | ||
// eslint-disable-next-line unicorn/prefer-math-min-max |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do Math.min(asset.fileModifiedAt, asset.fileCreatedAt)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it returns a number, but I can do new Date(Math.min(asset.fileModifiedAt, asset.fileCreatedAt))
instead if you prefer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer that, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Date.valueOf()
or Date.getTime()
also work.
new Date(Math.min(asset.fileModifiedAt.valueOf(), asset.fileCreatedAt.valueOf()))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to take either pill and instead just use luxon lmao. Do you think that's overkill or would it make things nicely readable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny enough luxon's min
/max
functions require a DateTime
instead of a Date
, so a conversion is going to have to happen somewhere anyway, which means something like:
DateTime.min(DateTime.fromJSDate(asset.fileModifiedAt), DateTime.fromJSDate(asset.fileCreatedAt)).toJSDate()
😅
…ation timestamps when missing exif tags
I also applied the date extraction for motion asset creation, tell me if I need to rollback this part, maybe it was wanted to not re-use
getDates
.Closes #14857