Handle permission error in shutil.move for *nix systems during the rename plugin.
This commit is contained in:
@@ -12,6 +12,7 @@ import os
|
||||
import re
|
||||
import shutil
|
||||
import traceback
|
||||
import errno
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
@@ -428,6 +429,14 @@ class Renamer(Plugin):
|
||||
except:
|
||||
log.error('Failed setting permissions for file: %s, %s', (dest, traceback.format_exc(1)))
|
||||
|
||||
except OSError, err:
|
||||
# Copying from a filesystem with octal permission to an NTFS file system causes a permission error. In this case ignore it.
|
||||
if not hasattr(os, 'chmod') or err.errno != errno.EPERM:
|
||||
raise
|
||||
else:
|
||||
if os.path.exists(dest):
|
||||
os.unlink(old)
|
||||
|
||||
except:
|
||||
log.error('Couldn\'t move file "%s" to "%s": %s', (old, dest, traceback.format_exc()))
|
||||
raise Exception
|
||||
|
||||
Reference in New Issue
Block a user