1
0
Fork 0

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

pull/3154/head
Jordi Boggiano 2014-07-23 19:03:55 +02:00
parent 1110074d5f
commit 904f2830e7
1 changed files with 10 additions and 6 deletions

View File

@ -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;
}
}