media.date_shot not updated from EXIF data due to order-of-operations bug
Describe the bug
When photos are scanned, the media.date_shot field is not being updated with the EXIF date, causing photos to be sorted by file modification time instead of the actual shot date in the timeline view.
To Reproduce 1.- Take an old photo and change the file date (either using touch or by editing the EXIF metadata). 2.- Import it as a new photo (use a different filename or import it from a different directory) to force an EXIF scan 3- The application orders the photo in the timeline based on the file modification date instead of the EXIF date.
Expected behavior
The expected behavior is that media.date_shot is populated from the EXIF timestamp, and the file date is only used as a fallback.
Screenshots If applicable, add screenshots to help explain your problem.
Your environment: Feel free to remove and add what you think might be useful.
- Are you using Docker? yes
- Database tested with mariadb and sqlite
- Browser [e.g. chrome, safari]
- Version [e.g. 2.0.0]
Additional context After taking a look at the code, it looks like the issue is an order-of-operations bug. The assignment happens after the database save, so it only updates the in-memory object, not the database.
In exif_task.go (lines 66–71), we just need to move the line:
media.DateShot = *exifData.DateShot
before
tx.Save(media)
Source: photoview/photoview