Replace all os.remove calls

os.remove raises an exception when deleting read-only files on
Windows. Replace all calls with calls to platform_utils.remove,
which deals with deals with that issue.

Change-Id: I4dc9e0c9a36b4238880520c69f5075eca40f3e66
This commit is contained in:
Renaud Paquay
2016-11-11 14:25:29 -08:00
parent e8595e9df7
commit 010fed7711
6 changed files with 43 additions and 24 deletions

View File

@ -489,7 +489,7 @@ later is required to fix a server side protocol bug.
for root, dirs, files in os.walk(path):
for f in files:
try:
os.remove(os.path.join(root, f))
platform_utils.remove(os.path.join(root, f))
except OSError:
print('Failed to remove %s' % os.path.join(root, f), file=sys.stderr)
failed = True
@ -500,7 +500,7 @@ later is required to fix a server side protocol bug.
for d in reversed(dirs_to_remove):
if platform_utils.islink(d):
try:
os.remove(d)
platform_utils.remove(d)
except OSError:
print('Failed to remove %s' % os.path.join(root, d), file=sys.stderr)
failed = True
@ -712,7 +712,7 @@ later is required to fix a server side protocol bug.
else: # Not smart sync or smart tag mode
if os.path.isfile(smart_sync_manifest_path):
try:
os.remove(smart_sync_manifest_path)
platform_utils.remove(smart_sync_manifest_path)
except OSError as e:
print('error: failed to remove existing smart sync override manifest: %s' %
e, file=sys.stderr)
@ -956,7 +956,7 @@ class _FetchTimes(object):
f.close()
except (IOError, ValueError):
try:
os.remove(self._path)
platform_utils.remove(self._path)
except OSError:
pass
self._times = {}
@ -980,7 +980,7 @@ class _FetchTimes(object):
f.close()
except (IOError, TypeError):
try:
os.remove(self._path)
platform_utils.remove(self._path)
except OSError:
pass