瀏覽代碼

Clear stat cache after calling filesystem commands

Jordi Boggiano 12 年之前
父節點
當前提交
61efd2998c
共有 1 個文件被更改,包括 13 次插入3 次删除
  1. 13 3
      src/Composer/Util/Filesystem.php

+ 13 - 3
src/Composer/Util/Filesystem.php

@@ -130,7 +130,7 @@ class Filesystem
         $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
         $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
 
-        if ( !file_exists($target)) {
+        if (!file_exists($target)) {
             mkdir($target, 0777, true);
         }
 
@@ -159,7 +159,12 @@ class Filesystem
         if (defined('PHP_WINDOWS_VERSION_BUILD')) {
             // Try to copy & delete - this is a workaround for random "Access denied" errors.
             $command = sprintf('xcopy %s %s /E /I /Q', escapeshellarg($source), escapeshellarg($target));
-            if (0 === $this->processExecutor->execute($command, $output)) {
+            $result = $this->processExecutor->execute($command, $output);
+
+            // clear stat cache because external processes aren't tracked by the php stat cache
+            clearstatcache();
+
+            if (0 === $result) {
                 $this->remove($source);
 
                 return;
@@ -170,7 +175,12 @@ class Filesystem
             // We do not use PHP's "rename" function here since it does not support
             // the case where $source, and $target are located on different partitions.
             $command = sprintf('mv %s %s', escapeshellarg($source), escapeshellarg($target));
-            if (0 === $this->processExecutor->execute($command)) {
+            $result = $this->processExecutor->execute($command, $output);
+
+            // clear stat cache because external processes aren't tracked by the php stat cache
+            clearstatcache();
+
+            if (0 === $result) {
                 return;
             }
         }