From 010fed771183c23c0e7d04a4e7292782f68de9db Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2016 14:25:29 -0800 Subject: 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 --- project.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'project.py') diff --git a/project.py b/project.py index 655b2024..338ce93c 100644 --- a/project.py +++ b/project.py @@ -65,7 +65,7 @@ def _lwrite(path, content): try: platform_utils.rename(lock, path) except OSError: - os.remove(lock) + platform_utils.remove(lock) raise @@ -250,7 +250,7 @@ class _CopyFile(object): try: # remove existing file first, since it might be read-only if os.path.exists(dest): - os.remove(dest) + platform_utils.remove(dest) else: dest_dir = os.path.dirname(dest) if not os.path.isdir(dest_dir): @@ -279,7 +279,7 @@ class _LinkFile(object): try: # remove existing file first, since it might be read-only if os.path.lexists(absDest): - os.remove(absDest) + platform_utils.remove(absDest) else: dest_dir = os.path.dirname(absDest) if not os.path.isdir(dest_dir): @@ -1242,7 +1242,7 @@ class Project(object): if not self._ExtractArchive(tarpath, path=topdir): return False try: - os.remove(tarpath) + platform_utils.remove(tarpath) except OSError as e: _warn("Cannot remove archive %s: %s", tarpath, str(e)) self._CopyAndLinkFiles() @@ -1302,7 +1302,7 @@ class Project(object): else: self._InitMirrorHead() try: - os.remove(os.path.join(self.gitdir, 'FETCH_HEAD')) + platform_utils.remove(os.path.join(self.gitdir, 'FETCH_HEAD')) except OSError: pass return True @@ -1812,7 +1812,7 @@ class Project(object): except GitError: return [], [] finally: - os.remove(temp_gitmodules_path) + platform_utils.remove(temp_gitmodules_path) names = set() paths = {} @@ -2104,7 +2104,7 @@ class Project(object): if old_packed != '': _lwrite(packed_refs, old_packed) else: - os.remove(packed_refs) + platform_utils.remove(packed_refs) self.bare_git.pack_refs('--all', '--prune') if is_sha1 and current_branch_only: @@ -2166,14 +2166,14 @@ class Project(object): ok = GitCommand(self, cmd, bare=True).Wait() == 0 if os.path.exists(bundle_dst): - os.remove(bundle_dst) + platform_utils.remove(bundle_dst) if os.path.exists(bundle_tmp): - os.remove(bundle_tmp) + platform_utils.remove(bundle_tmp) return ok def _FetchBundle(self, srcUrl, tmpPath, dstPath, quiet): if os.path.exists(dstPath): - os.remove(dstPath) + platform_utils.remove(dstPath) cmd = ['curl', '--fail', '--output', tmpPath, '--netrc', '--location'] if quiet: @@ -2183,7 +2183,7 @@ class Project(object): if size >= 1024: cmd += ['--continue-at', '%d' % (size,)] else: - os.remove(tmpPath) + platform_utils.remove(tmpPath) if 'http_proxy' in os.environ and 'darwin' == sys.platform: cmd += ['--proxy', os.environ['http_proxy']] with GetUrlCookieFile(srcUrl, quiet) as (cookiefile, _proxy): @@ -2217,7 +2217,7 @@ class Project(object): platform_utils.rename(tmpPath, dstPath) return True else: - os.remove(tmpPath) + platform_utils.remove(tmpPath) return False else: return False @@ -2390,7 +2390,7 @@ class Project(object): continue if os.path.exists(dst): if filecmp.cmp(stock_hook, dst, shallow=False): - os.remove(dst) + platform_utils.remove(dst) else: _warn("%s: Not replacing locally modified %s hook", self.relpath, name) @@ -2508,7 +2508,7 @@ class Project(object): # file doesn't either. if name in symlink_files and not os.path.lexists(src): try: - os.remove(dst) + platform_utils.remove(dst) except OSError: pass -- cgit v1.2.3-54-g00ecf