Archive manager tweaks to reduce file path lengths, fixes #2808
parent
1110074d5f
commit
904f2830e7
|
@ -14,7 +14,7 @@ namespace Composer\Package\Archiver;
|
||||||
|
|
||||||
use Composer\Downloader\DownloadManager;
|
use Composer\Downloader\DownloadManager;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Package\RootPackage;
|
use Composer\Package\RootPackageInterface;
|
||||||
use Composer\Util\Filesystem;
|
use Composer\Util\Filesystem;
|
||||||
use Composer\Json\JsonFile;
|
use Composer\Json\JsonFile;
|
||||||
|
|
||||||
|
@ -133,11 +133,11 @@ class ArchiveManager
|
||||||
return $target;
|
return $target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($package instanceof RootPackage) {
|
if ($package instanceof RootPackageInterface) {
|
||||||
$sourcePath = realpath('.');
|
$sourcePath = realpath('.');
|
||||||
} else {
|
} else {
|
||||||
// Directory used to download the sources
|
// 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);
|
$filesystem->ensureDirectoryExists($sourcePath);
|
||||||
|
|
||||||
// Download sources
|
// Download sources
|
||||||
|
@ -154,13 +154,17 @@ class ArchiveManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the archive
|
// 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
|
// cleanup temporary download
|
||||||
if (!$package instanceof RootPackage) {
|
if (!$package instanceof RootPackageInterface) {
|
||||||
$filesystem->removeDirectory($sourcePath);
|
$filesystem->removeDirectory($sourcePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $archivePath;
|
return $target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue