Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: git_cache.py

Issue 240653002: Make Lockfile._remove_lockfile more robust on win32 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fixed indentation Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698