Bug 1307482 - Avoid excessive scp calls to make directories; r?ted draft
authorGregory Szorc <gps@mozilla.com>
Tue, 04 Oct 2016 08:34:30 -0700 (2016-10-04)
changeset 426113 a082297b7802b14be2b90b326f4d0a704bd7868a
parent 426112 061aebb95c4b3f783a0ff5792de2134780158d01
child 426114 ddfa9759bd16c88f4a497f898c03ea17d7770fd4
push id32628
push userbmo:gps@mozilla.com
push dateMon, 17 Oct 2016 22:15:18 +0000 (2016-10-17)
reviewersted
bugs1307482
milestone52.0a1
Bug 1307482 - Avoid excessive scp calls to make directories; r?ted Most files go to the same directory. This should cut down on the number of scp sessions we establish as part of directory creation. MozReview-Commit-ID: LpKwgUZhLEO
build/upload.py
--- a/build/upload.py
+++ b/build/upload.py
@@ -227,22 +227,32 @@ def UploadFiles(user, host, path, files,
         base_path = os.path.abspath(base_path)
     remote_files = []
     properties = {}
 
     def get_remote_path(p):
         return GetBaseRelativePath(path, os.path.abspath(p), base_path)
 
     try:
+        # Do a pass to find remote directories so we don't perform excessive
+        # scp calls.
+        remote_paths = set()
         for file in files:
             if not os.path.isfile(file):
                 raise IOError("File not found: %s" % file)
-            # first ensure that path exists remotely
+
+            remote_paths.add(get_remote_path(file))
+
+        # If we wanted to, we could reduce the remote paths if they are a parent
+        # of any entry.
+        for p in sorted(remote_paths):
+            DoSSHCommand("mkdir -p " + p, user, host, port=port, ssh_key=ssh_key)
+
+        for file in files:
             remote_path = get_remote_path(file)
-            DoSSHCommand("mkdir -p " + remote_path, user, host, port=port, ssh_key=ssh_key)
             if verbose:
                 print "Uploading " + file
             DoSCPFile(file, remote_path, user, host, port=port, ssh_key=ssh_key)
             remote_files.append(remote_path + '/' + os.path.basename(file))
         if post_upload_command is not None:
             if verbose:
                 print "Running post-upload command: " + post_upload_command
             file_list = '"' + '" "'.join(remote_files) + '"'