Bug 1484790 - [fetches] Overwrite without prompting when unzipping an artifact with fetch-content, r=gps
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 24 Aug 2018 16:04:59 +0000
changeset 481671 11f24fdab55c4b1bc841a17f78aed9c762e2234b
parent 481670 1676f895a7102a9fab1a84c2a5e43449edd7f870
child 481672 17ffad06d94fa4b2753fd7324c96303d50b78c7f
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersgps
bugs1484790
milestone63.0a1
Bug 1484790 - [fetches] Overwrite without prompting when unzipping an artifact with fetch-content, r=gps This also moves the call to 'fetch_artifacts' in run-task down inside the try/finally block. This way if something goes wrong, we'll still cleanup MOZ_FETCHES_DIR. Differential Revision: https://phabricator.services.mozilla.com/D4152
taskcluster/scripts/misc/fetch-content
taskcluster/scripts/run-task
--- a/taskcluster/scripts/misc/fetch-content
+++ b/taskcluster/scripts/misc/fetch-content
@@ -186,17 +186,17 @@ def extract_archive(path, dest_dir, typ)
         else:
             raise ValueError('unknown archive format for tar file: %s' % path)
 
         args = ['tar', 'xf', '-']
         pipe_stdin = True
     elif typ == 'zip':
         # unzip from stdin has wonky behavior. We don't use a pipe for it.
         ifh = open(os.devnull, 'rb')
-        args = ['unzip', str(path)]
+        args = ['unzip', '-o', str(path)]
         pipe_stdin = False
     else:
         raise ValueError('unknown archive format: %s' % path)
 
     log('Extracting %s to %s using %r' % (path, dest_dir, args))
     t0 = time.time()
 
     with ifh, subprocess.Popen(args, cwd=str(dest_dir), bufsize=0,
--- a/taskcluster/scripts/run-task
+++ b/taskcluster/scripts/run-task
@@ -732,21 +732,21 @@ def main(args):
             revision=os.environ.get('COMM_HEAD_REV'),
             branch=os.environ.get('COMM_HEAD_REF'))
 
     elif not os.environ.get('COMM_HEAD_REV') and \
             os.environ.get('COMM_HEAD_REF'):
         print('task should be defined in terms of non-symbolic revision')
         return 1
 
-    fetches = os.environ.get('MOZ_FETCHES')
-    if fetches:
-        fetch_artifacts(fetches)
+    try:
+        fetches = os.environ.get('MOZ_FETCHES')
+        if fetches:
+            fetch_artifacts(fetches)
 
-    try:
         return run_and_prefix_output(b'task', task_args)
     finally:
         fetches_dir = os.environ.get('MOZ_FETCHES_DIR')
         if fetches_dir and os.path.isdir(fetches_dir):
             print_line(b'fetches', b'removing %s\n' % fetches_dir.encode('utf-8'))
             shutil.rmtree(fetches_dir)
             print_line(b'fetches', b'finished\n')