Zipball URLs for Subversion
Closed this issue · 2 comments
For packages stored in Subversion, packeton produces following dist URL (example);
https://packeton.myorg/zipball/myorg/mypackage//tags/1.0.1/@3426.zip
but the route for ZipballController::zipballAction
allows only URLs with 40 character hashes:
#[Route(
'/zipball/{package}/{hash}',
name: 'download_dist_package',
requirements: ['package' => '%package_name_regex%', 'hash' => '[a-f0-9]{40}\.[a-z]+?'],
methods: ['GET']
)]
For packages using Git, packeton produces valid zipball URLs.
Is it a bug, or I am doing something wrong?
My quick&dirty "fix":
#[Route(
'/zipball/{package}/{hash}',
name: 'download_dist_package',
- requirements: ['package' => '%package_name_regex%', 'hash' => '[a-f0-9]{40}\.[a-z]+?'],
+ requirements: ['package' => '%package_name_regex%', 'hash' => '.+?\.zip'],
methods: ['GET']
)]
public function zipballAction(#[Vars('name')] Package $package, string $hash): Response
{
if ((false === $this->dm->isEnabled() && false === RepTypes::isBuildInDist($package->getRepoType()))
- || !\preg_match('{[a-f0-9]{40}}i', $hash, $match) || !($reference = $match[0])
+ || !\preg_match('{(.+?)\.zip}i', $hash, $match) || !($reference = $match[1])
) {
return $this->createNotFound();
}
After this fix I also had to disable include_archive_checksum
option in config, because sha1 checksums were wrong for Subversion packages . I don't know why yet.
Strangely enough, it works on my development machine, but in docker the starting slash is missing (tags/1.0.1/@3426.zip
instead of /tags/1.0.1/@3426.zip
) so I had to also add:
if (str_contains($reference, '/') && !str_starts_with($reference, '/')) {
$reference = '/' . $reference;
}
I'll analyze later what is the root cause.