Commit 4e2ad846 authored by hinoka@chromium.org's avatar hinoka@chromium.org

Git Cache speculative fix for windows

Git cache sometimes fail on:
Traceback (most recent call last):
  File "E:\b\depot_tools\\gclient.py", line 2064, in <module>
    sys.exit(Main(sys.argv[1:]))
  File "E:\b\depot_tools\\gclient.py", line 2052, in Main
    return dispatcher.execute(OptionParser(), argv)
  File "E:\b\depot_tools\subcommand.py", line 245, in execute
    return command(parser, args[1:])
  File "E:\b\depot_tools\\gclient.py", line 1830, in CMDsync
    ret = client.RunOnDeps('update', args)
  File "E:\b\depot_tools\\gclient.py", line 1342, in RunOnDeps
    work_queue.flush(revision_overrides, command, args, options=self._options)
  File "E:\b\depot_tools\gclient_utils.py", line 852, in flush
    self._run_one_task(self.queued.pop(i), args, kwargs)
  File "E:\b\depot_tools\gclient_utils.py", line 944, in _run_one_task
    task_item.run(*args, **kwargs)
  File "E:\b\depot_tools\\gclient.py", line 744, in run
    file_list)
  File "E:\b\depot_tools\gclient_scm.py", line 160, in RunCommand
    return getattr(self, command)(options, args, file_list)
  File "E:\b\depot_tools\gclient_scm.py", line 387, in update
    self._UpdateMirror(mirror, options)
  File "E:\b\depot_tools\gclient_scm.py", line 802, in _UpdateMirror
    ignore_lock=options.ignore_locks)
  File "E:\b\depot_tools\git_cache.py", line 409, in populate
    os.rename(tempdir, self.mirror_path)
WindowsError: [Error 183] Cannot create a file when that file already exists

It would appear that its being racy, but otherwise it doesn't make any sense.  A theory
is that this could be running twice and stepping on each other.  Allowing this
to pass on OSError allows us to test this theory.

BUG=395333

Review URL: https://codereview.chromium.org/408653002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@284272 0039d316-1c4b-4281-b951-d872f2087c98
parent c2711005
......@@ -406,7 +406,14 @@ class Mirror(object):
self._fetch(tempdir or self.mirror_path, verbose, depth)
finally:
if tempdir:
os.rename(tempdir, self.mirror_path)
try:
os.rename(tempdir, self.mirror_path)
except OSError as e:
# This is somehow racy on Windows.
# Catching OSError because WindowsError isn't portable and
# pylint complains.
self.print('Error moving %s to %s: %s' % (tempdir, self.mirror_path,
str(e)))
if not ignore_lock:
lockfile.unlock()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment