summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-22 20:28:10 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-22 20:28:10 +0000
commit99935d739e2ac283a8ad43340131764da4e07d2e (patch)
tree16d3e4a6bd29b8fbfadfd0552b09c5d7ddefe3f6 /native_client_sdk
parentf4d6054e0df09c5de34358f99fb6e751fc1c4e2b (diff)
downloadchromium_src-99935d739e2ac283a8ad43340131764da4e07d2e.zip
chromium_src-99935d739e2ac283a8ad43340131764da4e07d2e.tar.gz
chromium_src-99935d739e2ac283a8ad43340131764da4e07d2e.tar.bz2
NaCl SDK: Speculative fix for RemoveDir problem
I can't reproduce, but this is an attempt to make RemoveDir not report error if it's used on a directory which doesn't exist. BUG= TEST= Review URL: http://codereview.chromium.org/9431035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-xnative_client_sdk/src/build_tools/sdk_tools/sdk_update.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/native_client_sdk/src/build_tools/sdk_tools/sdk_update.py b/native_client_sdk/src/build_tools/sdk_tools/sdk_update.py
index 9145aed..4f0c83b 100755
--- a/native_client_sdk/src/build_tools/sdk_tools/sdk_update.py
+++ b/native_client_sdk/src/build_tools/sdk_tools/sdk_update.py
@@ -27,7 +27,7 @@ import urlparse
# Bump the MINOR_REV every time you check this file in.
MAJOR_REV = 1
-MINOR_REV = 13
+MINOR_REV = 14
GLOBAL_HELP = '''Usage: naclsdk [options] command [command_options]
@@ -213,8 +213,7 @@ def ExtractInstaller(installer, outdir):
Raises:
CalledProcessError - if the extract operation fails'''
- if os.path.exists(outdir):
- RemoveDir(outdir)
+ RemoveDir(outdir)
if os.path.splitext(installer)[1] == '.exe':
# If the installer has extension 'exe', assume it's a Windows NSIS-style
@@ -238,7 +237,8 @@ def RemoveDir(outdir):
On Unix systems, this just runs shutil.rmtree, but on Windows, this doesn't
work when the directory contains junctions (as does our SDK installer).
Therefore, on Windows, it runs rmdir /S /Q as a shell command. This always
- does the right thing on Windows.
+ does the right thing on Windows. If the directory already didn't exist,
+ RemoveDir will return successfully without taking any action.
Args:
outdir: The directory to delete
@@ -249,10 +249,18 @@ def RemoveDir(outdir):
'''
DebugPrint('Removing %s' % outdir)
- if sys.platform == 'win32':
- subprocess.check_call(['rmdir /S /Q', outdir], shell=True)
- else:
- shutil.rmtree(outdir)
+ try:
+ if sys.platform == 'win32':
+ subprocess.check_call(['rmdir /S /Q', outdir], shell=True)
+ else:
+ shutil.rmtree(outdir)
+ except:
+ # If the directory is gone anyway, we probably failed because it was
+ # already gone. Treat that as success.
+ if not os.path.exists(outdir):
+ return
+ # Otherwise, re-raise.
+ raise
def RenameDir(srcdir, destdir):
@@ -263,8 +271,7 @@ def RenameDir(srcdir, destdir):
for num_tries in xrange(max_tries):
try:
- if os.path.exists(destdir):
- RemoveDir(destdir)
+ RemoveDir(destdir)
os.rename(srcdir, destdir)
return
except OSError as err: