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

Unified Diff: dart/editor/build/build.py

Issue 70223002: Only archive apidocs if they are not already there (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | dart/tools/bots/bot_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/editor/build/build.py
diff --git a/dart/editor/build/build.py b/dart/editor/build/build.py
index a4c598074bbbfb25c15e0d77b8f901d085d08821..5a0d35b5317a22250b8ac4f16f30ef97f3dacbaa 100755
--- a/dart/editor/build/build.py
+++ b/dart/editor/build/build.py
@@ -1187,8 +1187,13 @@ def UploadApiDocs(dirName):
apidocs_destination_gcsdir = apidocs_namer.docs_dirpath(REVISION)
apidocs_destination_latestfile = apidocs_namer.docs_latestpath(REVISION)
- # Delete the old revision specific apidocs directory if present.
- Gsutil(['-m', 'rm', '-R', '-f', apidocs_destination_gcsdir])
+ # Return early if the documents have already been uploaded.
+ # (This can happen if a build was forced, or a commit had no changes in the
+ # dart repository (e.g. DEPS file update).)
+ if GsutilExists(apidocs_destination_gcsdir):
+ print ("Not uploading api docs, since %s is already present."
+ % apidocs_destination_gcsdir)
+ return
# Upload everything inside the built apidocs directory.
Gsutil(['-m', 'cp', '-R', '-a', 'public-read', dirName,
@@ -1203,11 +1208,23 @@ def UploadApiDocs(dirName):
Gsutil(['cp', '-a', 'public-read', latest_file,
apidocs_destination_latestfile])
-
def Gsutil(cmd):
gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil')
ExecuteCommand([sys.executable, gsutilTool] + cmd)
+def GsutilExists(gsu_path):
+ gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil')
+ (_, stderr, returncode) = bot_utils.run(
+ [gsutilTool, 'ls', gsu_path],
+ throw_on_error=False)
+ # If the returncode is nonzero and we can find a specific error message,
+ # we know there are no objects with a prefix of [gsu_path].
+ missing = (returncode and 'CommandException: No such object' in stderr)
+ # Either the returncode has to be zero or the object must be missing,
+ # otherwise throw an exception.
+ if not missing and returncode:
+ raise Exception("Failed to determine whether %s exists" % gsu_path)
+ return not missing
def EnsureDirectoryExists(f):
d = os.path.dirname(f)
@@ -1233,6 +1250,5 @@ def FileDelete(f):
except OSError:
print 'error deleting %s' % f
-
if __name__ == '__main__':
sys.exit(main())
« no previous file with comments | « no previous file | dart/tools/bots/bot_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698