From c051066dd1c59edd09b8166e46b50b404dcc5133 Mon Sep 17 00:00:00 2001 From: Piotr Rogowski Date: Tue, 20 Oct 2020 20:43:04 +0200 Subject: [PATCH] Ensure that latest version is not removed when limit is applied --- .../PackageSynchronizer/ComposerPackageSynchronizer.php | 6 +++++- .../Security/PackageScanner/SensioLabsPackageScanner.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Service/PackageSynchronizer/ComposerPackageSynchronizer.php b/src/Service/PackageSynchronizer/ComposerPackageSynchronizer.php index 2c2c8855..d07de224 100644 --- a/src/Service/PackageSynchronizer/ComposerPackageSynchronizer.php +++ b/src/Service/PackageSynchronizer/ComposerPackageSynchronizer.php @@ -115,7 +115,11 @@ public function synchronize(Package $package): void $version['distType'] ); - if ($package->keepLastReleases() > 0 && count($encounteredVersions) >= $package->keepLastReleases()) { + if ( + $latest->getVersion() !== $version['version'] + && $package->keepLastReleases() > 0 + && count($encounteredVersions) >= $package->keepLastReleases() + ) { $this->distStorage->remove($dist); $package->removeVersion(new Version( Uuid::uuid4(), diff --git a/src/Service/Security/PackageScanner/SensioLabsPackageScanner.php b/src/Service/Security/PackageScanner/SensioLabsPackageScanner.php index b890ce96..03d50322 100644 --- a/src/Service/Security/PackageScanner/SensioLabsPackageScanner.php +++ b/src/Service/Security/PackageScanner/SensioLabsPackageScanner.php @@ -123,7 +123,7 @@ private function findDistribution(Package $package): string ); return $filename->getOrElseThrow( - new \RuntimeException('Distribution file not found') + new \RuntimeException("Distribution file for version $packageVersion not found") ); } }