diff options
author | Renaud Paquay <rpaquay@google.com> | 2016-11-11 14:25:29 -0800 |
---|---|---|
committer | Renaud Paquay <rpaquay@google.com> | 2017-08-31 13:49:36 -0700 |
commit | 010fed771183c23c0e7d04a4e7292782f68de9db (patch) | |
tree | 438b928fa1adaa7105d88462299513ca59c47c9f /project.py | |
parent | e8595e9df7980b0b7d9111de43d294c4439d474c (diff) | |
download | git-repo-010fed771183c23c0e7d04a4e7292782f68de9db.tar.gz |
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
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -65,7 +65,7 @@ def _lwrite(path, content): | |||
65 | try: | 65 | try: |
66 | platform_utils.rename(lock, path) | 66 | platform_utils.rename(lock, path) |
67 | except OSError: | 67 | except OSError: |
68 | os.remove(lock) | 68 | platform_utils.remove(lock) |
69 | raise | 69 | raise |
70 | 70 | ||
71 | 71 | ||
@@ -250,7 +250,7 @@ class _CopyFile(object): | |||
250 | try: | 250 | try: |
251 | # remove existing file first, since it might be read-only | 251 | # remove existing file first, since it might be read-only |
252 | if os.path.exists(dest): | 252 | if os.path.exists(dest): |
253 | os.remove(dest) | 253 | platform_utils.remove(dest) |
254 | else: | 254 | else: |
255 | dest_dir = os.path.dirname(dest) | 255 | dest_dir = os.path.dirname(dest) |
256 | if not os.path.isdir(dest_dir): | 256 | if not os.path.isdir(dest_dir): |
@@ -279,7 +279,7 @@ class _LinkFile(object): | |||
279 | try: | 279 | try: |
280 | # remove existing file first, since it might be read-only | 280 | # remove existing file first, since it might be read-only |
281 | if os.path.lexists(absDest): | 281 | if os.path.lexists(absDest): |
282 | os.remove(absDest) | 282 | platform_utils.remove(absDest) |
283 | else: | 283 | else: |
284 | dest_dir = os.path.dirname(absDest) | 284 | dest_dir = os.path.dirname(absDest) |
285 | if not os.path.isdir(dest_dir): | 285 | if not os.path.isdir(dest_dir): |
@@ -1242,7 +1242,7 @@ class Project(object): | |||
1242 | if not self._ExtractArchive(tarpath, path=topdir): | 1242 | if not self._ExtractArchive(tarpath, path=topdir): |
1243 | return False | 1243 | return False |
1244 | try: | 1244 | try: |
1245 | os.remove(tarpath) | 1245 | platform_utils.remove(tarpath) |
1246 | except OSError as e: | 1246 | except OSError as e: |
1247 | _warn("Cannot remove archive %s: %s", tarpath, str(e)) | 1247 | _warn("Cannot remove archive %s: %s", tarpath, str(e)) |
1248 | self._CopyAndLinkFiles() | 1248 | self._CopyAndLinkFiles() |
@@ -1302,7 +1302,7 @@ class Project(object): | |||
1302 | else: | 1302 | else: |
1303 | self._InitMirrorHead() | 1303 | self._InitMirrorHead() |
1304 | try: | 1304 | try: |
1305 | os.remove(os.path.join(self.gitdir, 'FETCH_HEAD')) | 1305 | platform_utils.remove(os.path.join(self.gitdir, 'FETCH_HEAD')) |
1306 | except OSError: | 1306 | except OSError: |
1307 | pass | 1307 | pass |
1308 | return True | 1308 | return True |
@@ -1812,7 +1812,7 @@ class Project(object): | |||
1812 | except GitError: | 1812 | except GitError: |
1813 | return [], [] | 1813 | return [], [] |
1814 | finally: | 1814 | finally: |
1815 | os.remove(temp_gitmodules_path) | 1815 | platform_utils.remove(temp_gitmodules_path) |
1816 | 1816 | ||
1817 | names = set() | 1817 | names = set() |
1818 | paths = {} | 1818 | paths = {} |
@@ -2104,7 +2104,7 @@ class Project(object): | |||
2104 | if old_packed != '': | 2104 | if old_packed != '': |
2105 | _lwrite(packed_refs, old_packed) | 2105 | _lwrite(packed_refs, old_packed) |
2106 | else: | 2106 | else: |
2107 | os.remove(packed_refs) | 2107 | platform_utils.remove(packed_refs) |
2108 | self.bare_git.pack_refs('--all', '--prune') | 2108 | self.bare_git.pack_refs('--all', '--prune') |
2109 | 2109 | ||
2110 | if is_sha1 and current_branch_only: | 2110 | if is_sha1 and current_branch_only: |
@@ -2166,14 +2166,14 @@ class Project(object): | |||
2166 | 2166 | ||
2167 | ok = GitCommand(self, cmd, bare=True).Wait() == 0 | 2167 | ok = GitCommand(self, cmd, bare=True).Wait() == 0 |
2168 | if os.path.exists(bundle_dst): | 2168 | if os.path.exists(bundle_dst): |
2169 | os.remove(bundle_dst) | 2169 | platform_utils.remove(bundle_dst) |
2170 | if os.path.exists(bundle_tmp): | 2170 | if os.path.exists(bundle_tmp): |
2171 | os.remove(bundle_tmp) | 2171 | platform_utils.remove(bundle_tmp) |
2172 | return ok | 2172 | return ok |
2173 | 2173 | ||
2174 | def _FetchBundle(self, srcUrl, tmpPath, dstPath, quiet): | 2174 | def _FetchBundle(self, srcUrl, tmpPath, dstPath, quiet): |
2175 | if os.path.exists(dstPath): | 2175 | if os.path.exists(dstPath): |
2176 | os.remove(dstPath) | 2176 | platform_utils.remove(dstPath) |
2177 | 2177 | ||
2178 | cmd = ['curl', '--fail', '--output', tmpPath, '--netrc', '--location'] | 2178 | cmd = ['curl', '--fail', '--output', tmpPath, '--netrc', '--location'] |
2179 | if quiet: | 2179 | if quiet: |
@@ -2183,7 +2183,7 @@ class Project(object): | |||
2183 | if size >= 1024: | 2183 | if size >= 1024: |
2184 | cmd += ['--continue-at', '%d' % (size,)] | 2184 | cmd += ['--continue-at', '%d' % (size,)] |
2185 | else: | 2185 | else: |
2186 | os.remove(tmpPath) | 2186 | platform_utils.remove(tmpPath) |
2187 | if 'http_proxy' in os.environ and 'darwin' == sys.platform: | 2187 | if 'http_proxy' in os.environ and 'darwin' == sys.platform: |
2188 | cmd += ['--proxy', os.environ['http_proxy']] | 2188 | cmd += ['--proxy', os.environ['http_proxy']] |
2189 | with GetUrlCookieFile(srcUrl, quiet) as (cookiefile, _proxy): | 2189 | with GetUrlCookieFile(srcUrl, quiet) as (cookiefile, _proxy): |
@@ -2217,7 +2217,7 @@ class Project(object): | |||
2217 | platform_utils.rename(tmpPath, dstPath) | 2217 | platform_utils.rename(tmpPath, dstPath) |
2218 | return True | 2218 | return True |
2219 | else: | 2219 | else: |
2220 | os.remove(tmpPath) | 2220 | platform_utils.remove(tmpPath) |
2221 | return False | 2221 | return False |
2222 | else: | 2222 | else: |
2223 | return False | 2223 | return False |
@@ -2390,7 +2390,7 @@ class Project(object): | |||
2390 | continue | 2390 | continue |
2391 | if os.path.exists(dst): | 2391 | if os.path.exists(dst): |
2392 | if filecmp.cmp(stock_hook, dst, shallow=False): | 2392 | if filecmp.cmp(stock_hook, dst, shallow=False): |
2393 | os.remove(dst) | 2393 | platform_utils.remove(dst) |
2394 | else: | 2394 | else: |
2395 | _warn("%s: Not replacing locally modified %s hook", | 2395 | _warn("%s: Not replacing locally modified %s hook", |
2396 | self.relpath, name) | 2396 | self.relpath, name) |
@@ -2508,7 +2508,7 @@ class Project(object): | |||
2508 | # file doesn't either. | 2508 | # file doesn't either. |
2509 | if name in symlink_files and not os.path.lexists(src): | 2509 | if name in symlink_files and not os.path.lexists(src): |
2510 | try: | 2510 | try: |
2511 | os.remove(dst) | 2511 | platform_utils.remove(dst) |
2512 | except OSError: | 2512 | except OSError: |
2513 | pass | 2513 | pass |
2514 | 2514 | ||