cleanup broken file db entries

This commit is contained in:
j 2016-03-28 15:51:08 +02:00
parent dcdf864dd7
commit 47647a7b86
1 changed files with 8 additions and 1 deletions

View File

@ -41,7 +41,14 @@ def remove_missing(books=None):
return
path = f.fullpath()
db_paths.append(path)
items[path] = f.sha1
if f.item:
items[path] = f.sha1
else:
state.db.session.delete(f)
dirty = True
if dirty:
state.db.session.commit()
dirty = False
removed = set(db_paths) - set(books)
if removed:
logger.debug('%s files removed', len(removed))