Commit:    5e27760dfdfe7fcdd00b127951f41cea2d453172
Author:    Anatol Belski <[email protected]>         Fri, 15 Sep 2017 13:26:46 +0200
Parents:   ce11cbf8b1ff5a799ad096ba8d226a383c93dcce
Branches:  master

Link:       
http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=5e27760dfdfe7fcdd00b127951f41cea2d453172

Log:
Fix source unzipping which previously might collide in parallel runs

Changed paths:
  M  include/Branch.php


Diff:
diff --git a/include/Branch.php b/include/Branch.php
index 2a20638..58e7f63 100644
--- a/include/Branch.php
+++ b/include/Branch.php
@@ -137,13 +137,24 @@ class Branch {
                        }
                }
                elseif ($is_zip === true)  {
-                       $cmd = 'unzip -q -o ' . $exportfile . ' -d ' . 
$build_dir;
+                       $extract_dir = $build_dir . DIRECTORY_SEPARATOR . 
"$build_type-$rev_name-tmp-unzip";
+                       if (true !== mkdir($extract_dir)) {
+                               throw new \Exception("Could not create 
temporary exctract dir under '$extract_dir'.");
+                       }
+
+                       $cmd = 'unzip -q -o ' . $exportfile . ' -d ' . 
$extract_dir;
                        $res = exec_single_log($cmd);
                        if (!$res) {
                                throw new \Exception("Unzipping $exportfile 
failed.");
                        }
                        $gitname = $build_dir . '/php-src-' . 
strtoupper($this->config->getName()) . '-' . $rev_name;
-                       rename($gitname, $target);
+                       if (true !== rename($gitname, $target)) {
+                               throw new \Exception("Failed to rename 
'$gitname' to '$target'");
+                       }
+
+                       if (true !== rmdir($extract_dir)) {
+                               throw new \Exception("Could not remove 
temporary exctract dir under '$extract_dir'.");
+                       }
                }
 
                $target = realpath($target);


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to