diff --git a/oml/item/models.py b/oml/item/models.py index 3541764..7f2702c 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -618,6 +618,8 @@ class File(db.Model): shutil.move(current_path, path) self.path = new_path self.save() + for folder in set(os.path.dirname(p) for p in [current_path, path]): + remove_empty_folders(folder) def save(self): state.db.session.add(self) diff --git a/oml/item/scan.py b/oml/item/scan.py index bf3ddea..07f3bcd 100644 --- a/oml/item/scan.py +++ b/oml/item/scan.py @@ -43,6 +43,11 @@ def remove_missing(): dirty = True if dirty: 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): user = state.user()