mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-12 21:22:17 +00:00
Fixed scanner for deleted folders
This commit is contained in:
parent
bb36b38d52
commit
09138897b9
@ -7,6 +7,7 @@
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
import logging
|
||||
import os, os.path
|
||||
import mimetypes
|
||||
import mutagen
|
||||
@ -22,6 +23,8 @@ from .db import StarredFolder, StarredArtist, StarredAlbum, StarredTrack
|
||||
from .db import RatingFolder, RatingTrack
|
||||
from .py23 import strtype, Queue, QueueEmpty
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class StatsDetails(object):
|
||||
def __init__(self):
|
||||
self.artists = 0
|
||||
@ -105,6 +108,8 @@ class Scanner(Thread):
|
||||
self.__stopped.set()
|
||||
|
||||
def __scan_folder(self, folder):
|
||||
logger.info('Scanning folder %s', folder.name)
|
||||
|
||||
if self.__on_folder_start is not None:
|
||||
self.__on_folder_start(folder)
|
||||
|
||||
@ -150,14 +155,15 @@ class Scanner(Thread):
|
||||
while not self.__stopped.is_set() and folders:
|
||||
f = folders.pop()
|
||||
|
||||
if not f.root and not os.path.isdir(f.path):
|
||||
with db_session:
|
||||
f = Folder[f.id] # f has been fetched from another session, refetch or Pony will complain
|
||||
|
||||
if not f.root and not os.path.isdir(f.path):
|
||||
f.delete() # Pony will cascade
|
||||
continue
|
||||
|
||||
self.find_cover(f.path)
|
||||
with db_session:
|
||||
folders += Folder[f.id].children # f has been fetched from another session, refetch or Pony will complain
|
||||
folders += f.children
|
||||
|
||||
if not self.__stopped.is_set():
|
||||
with db_session:
|
||||
|
Loading…
Reference in New Issue
Block a user