Abort scan when media folder is empty

This is to prevent all data being deleted in the case where a mount is not available
This commit is contained in:
Deluan 2020-10-30 09:39:36 -04:00
parent ba8d2f5da8
commit cdd44a2830
1 changed files with 6 additions and 0 deletions

View File

@ -98,6 +98,12 @@ func (s *TagScanner) Scan(ctx context.Context, lastModifiedSince time.Time) erro
}
}
// If the media folder is empty, abort to avoid deleting all data
if len(allFSDirs) <= 1 {
log.Error(ctx, "Media Folder is empty. Aborting scan.", "folder", s.rootFolder)
return nil
}
deletedDirs := s.getDeletedDirs(ctx, allFSDirs, allDBDirs)
if len(deletedDirs)+len(changedDirs) == 0 {
log.Debug(ctx, "No changes found in Music Folder", "folder", s.rootFolder)