1
Fork 0

Make sure not only new photos are scanned

Fix a small bug where a photo was marked as processed when it wasn't
This commit is contained in:
viktorstrate 2020-06-23 15:18:13 +02:00
parent 11c3a92373
commit e57a6f3dc0
2 changed files with 5 additions and 8 deletions

View File

@ -88,14 +88,14 @@ func ProcessPhoto(tx *sql.Tx, photo *models.Photo) (bool, error) {
if highResURL == nil {
didProcess = true
contentType, err := imageData.ContentType()
if err != nil {
return false, err
}
if !contentType.isWebCompatible() {
didProcess = true
highres_name := fmt.Sprintf("highres_%s_%s", path.Base(photo.Path), utils.GenerateToken())
highres_name = strings.ReplaceAll(highres_name, ".", "_")
highres_name = strings.ReplaceAll(highres_name, " ", "_")

View File

@ -36,7 +36,6 @@ func scanAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.DB) {
}
album_has_changes := false
for count, photo := range albumPhotos {
tx, err := db.Begin()
if err != nil {
@ -82,7 +81,7 @@ func scanAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.DB) {
func findPhotosForAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.DB, onScanPhoto func(photo *models.Photo, newPhoto bool)) ([]*models.Photo, error) {
newPhotos := make([]*models.Photo, 0)
albumPhotos := make([]*models.Photo, 0)
dirContent, err := ioutil.ReadDir(album.Path)
if err != nil {
@ -108,13 +107,11 @@ func findPhotosForAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.D
onScanPhoto(photo, isNewPhoto)
if isNewPhoto {
newPhotos = append(newPhotos, photo)
}
albumPhotos = append(albumPhotos, photo)
tx.Commit()
}
}
return newPhotos, nil
return albumPhotos, nil
}