diff --git a/api/scanner/media_type.go b/api/scanner/media_type.go index 08819611..5acfca59 100644 --- a/api/scanner/media_type.go +++ b/api/scanner/media_type.go @@ -1,6 +1,7 @@ package scanner import ( + "fmt" "io" "log" "os" @@ -231,10 +232,14 @@ func getMediaType(path string) (*MediaType, error) { ext := filepath.Ext(path) - fileExtType := fileExtensions[strings.ToLower(ext)] + fileExtType, found := fileExtensions[strings.ToLower(ext)] - if fileExtType.isSupported() { - return &fileExtType, nil + if found { + if fileExtType.isSupported() { + return &fileExtType, nil + } else { + return nil, errors.New(fmt.Sprintf("unsupported file type '%s' (%s)", ext, fileExtType)) + } } // If extension was not recognized try to read file header diff --git a/api/scanner/process_photo.go b/api/scanner/process_photo.go index bce18938..4a5ba70a 100644 --- a/api/scanner/process_photo.go +++ b/api/scanner/process_photo.go @@ -319,7 +319,7 @@ func processRawSideCar(tx *sql.Tx, imageData *EncodeMediaData, highResURL *model currentSideCarPath := scanForSideCarFile(photo.Path) if currentSideCarPath != nil { - currentFileHash := hashSideCarFile(currentSideCarPath) + currentFileHash = hashSideCarFile(currentSideCarPath) if photo.SideCarHash == nil || *photo.SideCarHash != *currentFileHash { sideCarFileHasChanged = true } @@ -354,7 +354,7 @@ func processRawSideCar(tx *sql.Tx, imageData *EncodeMediaData, highResURL *model // save new side car hash _, err = tx.Exec("UPDATE media SET side_car_hash = ?, side_car_path = ? WHERE media_id = ?", currentFileHash, currentSideCarPath, photo.MediaID) if err != nil { - return errors.Wrapf(err, "could not update side car hash (%d, %s)", photo.MediaID, *currentFileHash) + return errors.Wrapf(err, "could not update side car hash for media: %s", photo.Path) } } return nil