Browse Source

Check if file has moved, ignore copystat errors. close #2936

pull/2975/merge
Ruud 11 years ago
parent
commit
d60a8a71b7
  1. 22
      couchpotato/core/plugins/renamer/main.py

22
couchpotato/core/plugins/renamer/main.py

@ -736,8 +736,15 @@ Remove it if you want it to be renamed (again, or at least let it try again)
def moveFile(self, old, dest, forcemove = False):
dest = ss(dest)
try:
if forcemove:
shutil.move(old, dest)
if forcemove or self.conf('file_action') not in ['copy', 'link']:
try:
shutil.move(old, dest)
except:
if os.path.exists(dest):
log.error('Successfully moved file "%s", but something went wrong: %s', (dest, traceback.format_exc()))
os.unlink(old)
else:
raise
elif self.conf('file_action') == 'copy':
shutil.copy(old, dest)
elif self.conf('file_action') == 'link':
@ -755,8 +762,6 @@ Remove it if you want it to be renamed (again, or at least let it try again)
os.rename(old + '.link', old)
except:
log.error('Couldn\'t symlink file "%s" to "%s". Copied instead. Error: %s. ', (old, dest, traceback.format_exc()))
else:
shutil.move(old, dest)
try:
os.chmod(dest, Env.getPermission('file'))
@ -764,15 +769,6 @@ Remove it if you want it to be renamed (again, or at least let it try again)
os.popen('icacls "' + dest + '"* /reset /T')
except:
log.error('Failed setting permissions for file: %s, %s', (dest, traceback.format_exc(1)))
except OSError as 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

Loading…
Cancel
Save