Remove tracks from DB that were deleted while Navidrome was not running. Fixes #151

This commit is contained in:
Deluan
2020-06-12 13:26:46 -04:00
committed by Deluan Quintão
parent 01919661e9
commit e73b71aaf7
5 changed files with 71 additions and 11 deletions
+4 -7
View File
@@ -8,6 +8,7 @@ import (
"github.com/deluan/navidrome/consts"
"github.com/deluan/navidrome/log"
"github.com/deluan/navidrome/utils"
)
type dirInfo struct {
@@ -104,15 +105,11 @@ func isDirIgnored(baseDir string, dirInfo os.FileInfo) bool {
// isDirReadable returns true if the directory represented by dirInfo is readable
func isDirReadable(baseDir string, dirInfo os.FileInfo) bool {
path := filepath.Join(baseDir, dirInfo.Name())
dir, err := os.Open(path)
if err != nil {
res, err := utils.IsDirReadable(path)
if !res {
log.Debug("Warning: Skipping unreadable directory", "path", path, err)
return false
}
if err := dir.Close(); err != nil {
log.Error("Error closing directory", "path", path, err)
}
return true
return res
}
func (s *ChangeDetector) loadMap(dirMap dirInfoMap, path string, since time.Time, maybe bool) error {