Handle permission error in shutil.move for *nix systems during the rename plugin.

This commit is contained in:
Ruud
2012-08-05 15:39:04 +02:00
parent a3895dd176
commit 40daba277b
+9
View File
@@ -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