move files;cleanup empty folders

This commit is contained in:
j 2016-01-14 16:14:11 +05:30
parent 4b5fedb7a8
commit 173fde1d1b
2 changed files with 7 additions and 0 deletions

View file

@ -618,6 +618,8 @@ class File(db.Model):
shutil.move(current_path, path) shutil.move(current_path, path)
self.path = new_path self.path = new_path
self.save() self.save()
for folder in set(os.path.dirname(p) for p in [current_path, path]):
remove_empty_folders(folder)
def save(self): def save(self):
state.db.session.add(self) state.db.session.add(self)

View file

@ -43,6 +43,11 @@ def remove_missing():
dirty = True dirty = True
if dirty: if dirty:
state.db.session.commit() state.db.session.commit()
for f in File.query:
if not state.tasks.connected:
return
f.move()
remove_empty_folders(prefix)
def add_file(id, f, prefix, from_=None): def add_file(id, f, prefix, from_=None):
user = state.user() user = state.user()