diff --git a/oml/item/models.py b/oml/item/models.py index f894cfc..27e4191 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -797,6 +797,8 @@ class File(db.Model): shutil.move(current_path, path) except: logger.debug('failed to move %s to %s', current_path, path, exc_info=True) + if os.path.exists(path) and os.path.exists(current_path): + os.unlink(path) return self.path = new_path self.save()