Skip to content

Commit

Permalink
Added check to prevent multiple copy operations of the same file
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianKresse committed Nov 8, 2024
1 parent b80b0f6 commit d1b4855
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/InstallerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

class InstallerPlugin implements PluginInterface
{
private $ioncubeLicensesMemoize = null;

public function activate(Composer $composer, IOInterface $io)
{
$eventDispatcher = $composer->getEventDispatcher();
Expand Down Expand Up @@ -47,7 +49,7 @@ public function onInstallOrUpdate(PackageEvent $event)
} else {
// if a non license was installed - check whether this package requires a license and copy all required
// licenses into the package
$this->installAllLicenseInPackage(
$this->installAllLicensesInPackage(
$event->getComposer()->getInstallationManager(),
$event->getLocalRepo(),
$package
Expand Down Expand Up @@ -85,7 +87,7 @@ protected function installLicenseInAllRelatedPackages(
}
}

protected function installAllLicenseInPackage(
protected function installAllLicensesInPackage(
InstallationManager $installationManager,
RepositoryInterface $localRepo,
PackageInterface $targetPackage
Expand Down Expand Up @@ -134,6 +136,12 @@ protected function installLicenseInPackage(
if ($fileInfo->isDir() || strtolower($fileInfo->getExtension()) !== 'icl') {
continue;
}
$source = $fileInfo->getPathname();
$target = $targetDirectory . '/' . $fileInfo->getFilename();
if (file_exists($target) && \hash_file('md5', $source) === \hash_file('md5', $target)) {
continue;
}

copy($fileInfo->getPathname(), $targetDirectory . '/' . $fileInfo->getFilename());
}
}
Expand Down

0 comments on commit d1b4855

Please sign in to comment.