cleanup broken file db entries

This commit is contained in:
j 2016-03-28 15:51:08 +02:00
parent dcdf864dd7
commit 47647a7b86

View file

@ -41,7 +41,14 @@ def remove_missing(books=None):
return return
path = f.fullpath() path = f.fullpath()
db_paths.append(path) 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) removed = set(db_paths) - set(books)
if removed: if removed:
logger.debug('%s files removed', len(removed)) logger.debug('%s files removed', len(removed))