1
Fork 0

Ignore hidden media files

This closes #57
This commit is contained in:
viktorstrate 2020-08-12 12:31:13 +02:00
parent f94d5c6755
commit cdb4089f19
1 changed files with 11 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import (
"io"
"log"
"os"
"path"
"path/filepath"
"strings"
@ -265,16 +266,21 @@ func getMediaType(path string) (*MediaType, error) {
return nil, nil
}
func isPathMedia(path string, cache *AlbumScannerCache) bool {
mediaType, err := cache.GetMediaType(path)
func isPathMedia(mediaPath string, cache *AlbumScannerCache) bool {
mediaType, err := cache.GetMediaType(mediaPath)
if err != nil {
ScannerError("%s (%s)", err, path)
ScannerError("%s (%s)", err, mediaPath)
return false
}
// Ignore hidden files
if path.Base(mediaPath)[0:1] == "." {
return false
}
if mediaType != nil {
// Make sure file isn't empty
fileStats, err := os.Stat(path)
fileStats, err := os.Stat(mediaPath)
if err != nil || fileStats.Size() == 0 {
return false
}
@ -282,6 +288,6 @@ func isPathMedia(path string, cache *AlbumScannerCache) bool {
return true
}
log.Printf("File is not a supported media %s\n", path)
log.Printf("File is not a supported media %s\n", mediaPath)
return false
}