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

Catch validation errors when creating/updating tracks

Closes #162
This commit is contained in:
Alban Féron 2019-08-25 15:05:23 +02:00
parent 9dd7d8a58b
commit ff0a9475d4
No known key found for this signature in database
GPG Key ID: 8CE0313646D16165

View File

@ -265,8 +265,12 @@ class Scanner(Thread):
trdict["artist"] = trartist trdict["artist"] = trartist
trdict["created"] = datetime.fromtimestamp(mtime) trdict["created"] = datetime.fromtimestamp(mtime)
try:
Track(**trdict) Track(**trdict)
self.__stats.added.tracks += 1 self.__stats.added.tracks += 1
except ValueError:
# Field validation error
self.__stats.errors.append(path)
else: else:
if tr.album.id != tralbum.id: if tr.album.id != tralbum.id:
trdict["album"] = tralbum trdict["album"] = tralbum
@ -274,7 +278,11 @@ class Scanner(Thread):
if tr.artist.id != trartist.id: if tr.artist.id != trartist.id:
trdict["artist"] = trartist trdict["artist"] = trartist
try:
tr.set(**trdict) tr.set(**trdict)
except ValueError:
# Field validation error
self.__stats.errors.append(path)
@db_session @db_session
def remove_file(self, path): def remove_file(self, path):