move can fail

This commit is contained in:
j 2016-03-26 17:55:22 +01:00
parent 8872141032
commit dcdf864dd7
1 changed files with 5 additions and 1 deletions

View File

@ -787,7 +787,11 @@ class File(db.Model):
if self.path != new_path:
path = os.path.join(prefix, new_path)
ox.makedirs(os.path.dirname(path))
shutil.move(current_path, path)
try:
shutil.move(current_path, path)
except:
logger.debug('failed to move %s to %s', current_path, path, exc_info=True)
return
self.path = new_path
self.save()
for folder in set(os.path.dirname(p) for p in [current_path, path]):