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)
|
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()
|
||||||
|
|
Loading…
Reference in a new issue