From 9cea9e514505284d19a6e5d71f43a3fd723e8638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 21 Apr 2024 01:11:33 +0200 Subject: [PATCH] Dedup install path computation --- src/ExtensionInstaller.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ExtensionInstaller.php b/src/ExtensionInstaller.php index 12bdead..166ee98 100644 --- a/src/ExtensionInstaller.php +++ b/src/ExtensionInstaller.php @@ -70,7 +70,7 @@ public function install(InstalledRepositoryInterface $repo, PackageInterface $pa $postInstall = function () use ($package) { $config_file = $this->rcubeConfigFile(); $package_name = $this->getPackageName($package); - $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; + $package_dir = $this->getInstallPath($package); $extra = $package->getExtra(); if (is_writable($config_file) && \PHP_SAPI === 'cli' && $this->confirmInstall($package_name)) { @@ -143,8 +143,7 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini $fs = new Filesystem(); // backup persistent files e.g. config.inc.php - $package_name = $this->getPackageName($initial); - $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; + $package_dir = $this->getInstallPath($initial); $temp_dir = $package_dir . '-' . sprintf('%010d%010d', mt_rand(), mt_rand()); // make a backup of existing files (for restoring persistent files) @@ -152,7 +151,7 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini $postUpdate = function () use ($target, $extra, $fs, $temp_dir) { $package_name = $this->getPackageName($target); - $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; + $package_dir = $this->getInstallPath($target); // restore persistent files $persistent_files = !empty($extra['roundcube']['persistent-files']) ? $extra['roundcube']['persistent-files'] : ['config.inc.php']; @@ -217,7 +216,7 @@ public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $ $postUninstall = function () use ($package, $config) { // post-uninstall: deactivate package $package_name = $this->getPackageName($package); - $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; + $package_dir = $this->getInstallPath($package); $this->rcubeAlterConfig($package_name, false); @@ -400,7 +399,7 @@ private function rcubeRunScript($script, PackageInterface $package) { $package_name = $this->getPackageName($package); $package_type = $package->getType(); - $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; + $package_dir = $this->getInstallPath($package); // check for executable shell script if (($scriptfile = realpath($package_dir . \DIRECTORY_SEPARATOR . $script)) && is_executable($scriptfile)) { @@ -424,7 +423,7 @@ private function rcubeRunScript($script, PackageInterface $package) } /** - * normalize Roundcube version string. + * Normalize Roundcube version string. */ private static function versionNormalize(string $version): string {