Generate a properly unique archive filename for dev revisions
parent
0b23643a44
commit
48dd55b759
|
@ -45,6 +45,29 @@ class ArchiveManager
|
||||||
$this->archivers[] = $archiver;
|
$this->archivers[] = $archiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a distinct filename for a particular version of a package.
|
||||||
|
*
|
||||||
|
* @param PackageInterface $package The package to get a name for
|
||||||
|
*
|
||||||
|
* @return string A filename without an extension
|
||||||
|
*/
|
||||||
|
protected function getPackageFilename(PackageInterface $package)
|
||||||
|
{
|
||||||
|
$nameParts = array(preg_replace('#[^a-z0-9-_.]#i', '-', $package->getName()));
|
||||||
|
|
||||||
|
if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
|
||||||
|
$nameParts = array_merge($nameParts, array($package->getDistReference(), $package->getDistType()));
|
||||||
|
} else {
|
||||||
|
$nameParts = array_merge($nameParts, array($package->getPrettyVersion(), $package->getDistReference(), $package->getDistType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode('-', array_filter($nameParts, function ($p) {
|
||||||
|
return !empty($p);
|
||||||
|
}));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an archive of the specified package.
|
* Create an archive of the specified package.
|
||||||
*
|
*
|
||||||
|
@ -75,7 +98,7 @@ class ArchiveManager
|
||||||
}
|
}
|
||||||
|
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$packageName = preg_replace('#[^a-z0-9-_.]#i', '-', $package->getPrettyString());
|
$packageName = $this->getPackageFilename($package);
|
||||||
|
|
||||||
// Archive filename
|
// Archive filename
|
||||||
$filesystem->ensureDirectoryExists($targetDir);
|
$filesystem->ensureDirectoryExists($targetDir);
|
||||||
|
|
Loading…
Reference in New Issue