cleanup orphan file records

This commit is contained in:
j 2016-01-11 19:59:55 +05:30
parent 8fa5d10122
commit 10acaacbd9

View file

@ -33,10 +33,14 @@ def remove_missing():
for f in File.query: for f in File.query:
if not state.tasks.connected: if not state.tasks.connected:
return return
if f.item:
path = f.item.get_path() path = f.item.get_path()
if not os.path.exists(path): if not os.path.exists(path):
dirty = True dirty = True
f.item.remove_file() f.item.remove_file()
else:
state.db.session.delete(f)
dirty = True
if dirty: if dirty:
state.db.session.commit() state.db.session.commit()