fix(scanner): always refresh folder image time when adding first image (#3764)

* fix(scanner): Always refresh folder image time when adding first image

Currently, the `images_updated_at` field is only set to the image modification time.
However, in cases where a new image is added _and_ said image is older than the folder mod time, the field is not updated properly.

In this the case where `images_updated_at` is null (no images were ever added) and a new images is found, use the folder modification time instead of image modification time.

**Note**, this doesn't handle cases such as replacing a newer image with an older one.

* simplify image update at

* we don't want to set imagesUpdatedAt when there's no images in the folder

Signed-off-by: Deluan <deluan@navidrome.org>

---------

Signed-off-by: Deluan <deluan@navidrome.org>
Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Kendall Garner
2025-03-07 03:16:37 +00:00
committed by GitHub
parent 1c192d8a6d
commit 36ed880e61
3 changed files with 43 additions and 3 deletions
+13
View File
@@ -0,0 +1,13 @@
package utils
import "time"
func TimeNewest(times ...time.Time) time.Time {
newest := time.Time{}
for _, t := range times {
if t.After(newest) {
newest = t
}
}
return newest
}