Make sure album is updated if external cover changes

This commit is contained in:
Deluan 2022-12-23 10:51:21 -05:00 committed by Deluan Quintão
parent f5719a7571
commit 9ec349dce0
4 changed files with 28 additions and 11 deletions

View file

@ -20,6 +20,7 @@ type (
Path string
ModTime time.Time
Images []string
ImagesUpdatedAt time.Time
HasPlaylist bool
AudioFilesCount uint32
}
@ -93,12 +94,15 @@ func loadDir(ctx context.Context, dirPath string) ([]string, *dirStats, error) {
if fileInfo.ModTime().After(stats.ModTime) {
stats.ModTime = fileInfo.ModTime()
}
if utils.IsAudioFile(entry.Name()) {
switch {
case utils.IsAudioFile(entry.Name()):
stats.AudioFilesCount++
} else {
stats.HasPlaylist = stats.HasPlaylist || model.IsValidPlaylist(entry.Name())
if utils.IsImageFile(entry.Name()) {
stats.Images = append(stats.Images, entry.Name())
case model.IsValidPlaylist(entry.Name()):
stats.HasPlaylist = true
case utils.IsImageFile(entry.Name()):
stats.Images = append(stats.Images, entry.Name())
if fileInfo.ModTime().After(stats.ImagesUpdatedAt) {
stats.ImagesUpdatedAt = fileInfo.ModTime()
}
}
}