Fix bugs and improvements
- Fix a deadlock in the scanner cache - Cleanup error messages and logs
This commit is contained in:
parent
e57a6f3dc0
commit
23461ee707
|
@ -35,7 +35,7 @@ func (c *AlbumScannerCache) InsertAlbumPaths(end_path string, root string, conta
|
|||
|
||||
for curr_path != root_path || curr_path == "." {
|
||||
|
||||
c.InsertAlbumPath(curr_path, contains_photo)
|
||||
c.path_contains_photos[curr_path] = contains_photo
|
||||
|
||||
curr_path = path.Dir(curr_path)
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ func scanAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.DB) {
|
|||
if err != nil {
|
||||
tx.Rollback()
|
||||
ScannerError("Failed to process photo (%s): %s", photo.Path, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if processing_was_needed {
|
||||
|
@ -100,7 +101,7 @@ func findPhotosForAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.D
|
|||
|
||||
photo, isNewPhoto, err := ScanPhoto(tx, photoPath, album.AlbumID)
|
||||
if err != nil {
|
||||
ScannerError("Scanning image (%s): %s", photoPath, err)
|
||||
ScannerError("Scanning image error (%s): %s", photoPath, err)
|
||||
tx.Rollback()
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -9,9 +9,6 @@ import (
|
|||
)
|
||||
|
||||
func ScanPhoto(tx *sql.Tx, photoPath string, albumId int) (*models.Photo, bool, error) {
|
||||
|
||||
log.Printf("Scanning image: %s\n", photoPath)
|
||||
|
||||
photoName := path.Base(photoPath)
|
||||
|
||||
// Check if image already exists
|
||||
|
@ -28,6 +25,8 @@ func ScanPhoto(tx *sql.Tx, photoPath string, albumId int) (*models.Photo, bool,
|
|||
}
|
||||
}
|
||||
|
||||
log.Printf("Scanning image: %s\n", photoPath)
|
||||
|
||||
result, err := tx.Exec("INSERT INTO photo (title, path, album_id) VALUES (?, ?, ?)", photoName, photoPath, albumId)
|
||||
if err != nil {
|
||||
log.Printf("ERROR: Could not insert photo into database")
|
||||
|
|
Loading…
Reference in New Issue