move can fail

This commit is contained in:
j 2016-03-26 17:55:22 +01:00
parent 8872141032
commit dcdf864dd7

View file

@ -787,7 +787,11 @@ class File(db.Model):
if self.path != new_path: if self.path != new_path:
path = os.path.join(prefix, new_path) path = os.path.join(prefix, new_path)
ox.makedirs(os.path.dirname(path)) ox.makedirs(os.path.dirname(path))
try:
shutil.move(current_path, path) 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.path = new_path
self.save() self.save()
for folder in set(os.path.dirname(p) for p in [current_path, path]): for folder in set(os.path.dirname(p) for p in [current_path, path]):