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
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 93fea23..cda47fd 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -489,7 +489,7 @@
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 @@
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 @@
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 @@
f.close()
except (IOError, ValueError):
try:
- os.remove(self._path)
+ platform_utils.remove(self._path)
except OSError:
pass
self._times = {}
@@ -980,7 +980,7 @@
f.close()
except (IOError, TypeError):
try:
- os.remove(self._path)
+ platform_utils.remove(self._path)
except OSError:
pass