unlink target if move failed

This commit is contained in:
j 2019-01-13 00:28:01 +05:30
parent 3d1a629970
commit a01e574a8f

View file

@ -797,6 +797,8 @@ class File(db.Model):
shutil.move(current_path, path) shutil.move(current_path, path)
except: except:
logger.debug('failed to move %s to %s', current_path, path, exc_info=True) 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 return
self.path = new_path self.path = new_path
self.save() self.save()