Handle permission error in shutil.move for *nix systems during the rename plugin.
This commit is contained in:
1 parent
a3895dd176
commit
40daba277b
1 file changed
+9
@@ -12,6 +12,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import traceback
|
import traceback
|
||||||
|
import errno
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -428,6 +429,14 @@ class Renamer(Plugin):
|
|||||||
except:
|
except:
|
||||||
log.error('Failed setting permissions for file: %s, %s', (dest, traceback.format_exc(1)))
|
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:
|
except:
|
||||||
log.error('Couldn\'t move file "%s" to "%s": %s', (old, dest, traceback.format_exc()))
|
log.error('Couldn\'t move file "%s" to "%s": %s', (old, dest, traceback.format_exc()))
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|||||||
Reference in new issue
Block a user