unlink target if move failed
This commit is contained in:
parent
3d1a629970
commit
a01e574a8f
1 changed files with 2 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue