فهرست منبع

Archive manager tweaks to reduce file path lengths, fixes #2808

Jordi Boggiano 11 سال پیش
والد
کامیت
904f2830e7
1فایلهای تغییر یافته به همراه10 افزوده شده و 6 حذف شده
  1. 10 6
      src/Composer/Package/Archiver/ArchiveManager.php

+ 10 - 6
src/Composer/Package/Archiver/ArchiveManager.php

@@ -14,7 +14,7 @@ namespace Composer\Package\Archiver;
 
 use Composer\Downloader\DownloadManager;
 use Composer\Package\PackageInterface;
-use Composer\Package\RootPackage;
+use Composer\Package\RootPackageInterface;
 use Composer\Util\Filesystem;
 use Composer\Json\JsonFile;
 
@@ -133,11 +133,11 @@ class ArchiveManager
             return $target;
         }
 
-        if ($package instanceof RootPackage) {
+        if ($package instanceof RootPackageInterface) {
             $sourcePath = realpath('.');
         } else {
             // Directory used to download the sources
-            $sourcePath = sys_get_temp_dir().'/composer_archiver/'.$packageName;
+            $sourcePath = sys_get_temp_dir().'/composer_archiver/arch'.uniqid();
             $filesystem->ensureDirectoryExists($sourcePath);
 
             // Download sources
@@ -154,13 +154,17 @@ class ArchiveManager
         }
 
         // Create the archive
-        $archivePath = $usableArchiver->archive($sourcePath, $target, $format, $package->getArchiveExcludes());
+        $tempTarget = sys_get_temp_dir().'/composer_archiver/arch'.uniqid().'.'.$format;
+        $filesystem->ensureDirectoryExists(dirname($tempTarget));
+
+        $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes());
+        rename($archivePath, $target);
 
         // cleanup temporary download
-        if (!$package instanceof RootPackage) {
+        if (!$package instanceof RootPackageInterface) {
             $filesystem->removeDirectory($sourcePath);
         }
 
-        return $archivePath;
+        return $target;
     }
 }