1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-10 04:02:17 +00:00

Removed bulk deletes from scanner

Was causing either cache issues or constraint errors
Fixes #103, #102
This commit is contained in:
spl0k 2018-07-29 17:58:20 +02:00
parent 78cf84e136
commit b25e943e4e
2 changed files with 4 additions and 4 deletions

View File

@ -107,7 +107,7 @@ class Folder(PathMixin, db.Entity):
not exists(f for f in Folder if f.parent == self) and not self.root) not exists(f for f in Folder if f.parent == self) and not self.root)
total = 0 total = 0
while True: while True:
count = query.delete() # Non-bulk, MariaDB<10.3.1 doesn't like it count = query.delete()
total += count total += count
if not count: if not count:
return total return total
@ -140,7 +140,7 @@ class Artist(db.Entity):
@classmethod @classmethod
def prune(cls): def prune(cls):
return cls.select(lambda self: not exists(a for a in Album if a.artist == self) and \ return cls.select(lambda self: not exists(a for a in Album if a.artist == self) and \
not exists(t for t in Track if t.artist == self)).delete(bulk = True) not exists(t for t in Track if t.artist == self)).delete()
class Album(db.Entity): class Album(db.Entity):
_table_ = 'album' _table_ = 'album'
@ -180,7 +180,7 @@ class Album(db.Entity):
@classmethod @classmethod
def prune(cls): def prune(cls):
return cls.select(lambda self: not exists(t for t in Track if t.album == self)).delete(bulk = True) return cls.select(lambda self: not exists(t for t in Track if t.album == self)).delete()
class Track(PathMixin, db.Entity): class Track(PathMixin, db.Entity):
_table_ = 'track' _table_ = 'track'

View File

@ -87,7 +87,7 @@ class Scanner:
f = folders.pop() f = folders.pop()
if not f.root and not os.path.isdir(f.path): if not f.root and not os.path.isdir(f.path):
Folder.select(lambda sub: sub.path.startswith(f.path)).delete(bulk = True) f.delete() # Pony will cascade
continue continue
album_name = None album_name = None