Index: git_cache.py |
diff --git a/git_cache.py b/git_cache.py |
index 88c55e611dbb9f2fbd5d997a649f76edde7facd8..5c1f85a46eeaa454d280dfe89c1550f012894683 100755 |
--- a/git_cache.py |
+++ b/git_cache.py |
@@ -11,6 +11,7 @@ import logging |
import optparse |
import os |
import tempfile |
+import time |
import subprocess |
import sys |
import urlparse |
@@ -60,8 +61,22 @@ class Lockfile(object): |
f.close() |
def _remove_lockfile(self): |
- """Delete the lockfile. Complains (implicitly) if it doesn't exist.""" |
- os.remove(self.lockfile) |
+ """Delete the lockfile. Complains (implicitly) if it doesn't exist. |
M-A Ruel
2014/04/17 17:17:19
Deletes :)
|
+ |
+ See gclient_utils.py:rmtree docstring for more explanation on the |
+ windows case. |
+ """ |
+ if sys.platform == 'win32': |
+ lockfile = os.path.normcase(self.lockfile) |
+ for _ in xrange(3): |
+ exitcode = subprocess.call(['cmd.exe', '/c', |
+ 'del', '/f', '/q', lockfile]) |
+ if exitcode == 0: |
+ return |
+ time.sleep(3) |
+ raise LockError('Failed to remove lock: %s' % lockfile) |
+ else: |
+ os.remove(self.lockfile) |
def lock(self): |
"""Acquire the lock. |