diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php index eaa05297..94f7ce56 100644 --- a/lib/Controller/OtherController.php +++ b/lib/Controller/OtherController.php @@ -122,7 +122,7 @@ class OtherController extends GenericApiController // Check exiftool version $exiftoolNoLocal = Util::getSystemConfig('memories.exiftool_no_local'); $status['exiftool'] = $this->getExecutableStatus( - BinExt::getExiftoolPBin(), + fn () => BinExt::getExiftoolPBin(), fn ($p) => BinExt::testExiftool(), !$exiftoolNoLocal, !$exiftoolNoLocal, @@ -253,10 +253,10 @@ class OtherController extends GenericApiController /** * Get the status of an executable. * - * @param string $path Path to the executable - * @param ?\Closure $testFunction Function to test the executable - * @param bool $testIfFile Test if the path is a file - * @param bool $testIfExecutable Test if the path is executable + * @param \Closure|string $path Path to the executable + * @param ?\Closure $testFunction Function to test the executable + * @param bool $testIfFile Test if the path is a file + * @param bool $testIfExecutable Test if the path is executable */ private function getExecutableStatus( $path, @@ -264,6 +264,14 @@ class OtherController extends GenericApiController bool $testIfFile = true, bool $testIfExecutable = true ): string { + if ($path instanceof \Closure) { + try { + $path = $path(); + } catch (\Exception $e) { + return 'test_fail:'.$e->getMessage(); + } + } + if (!\is_string($path)) { return 'not_found'; } diff --git a/lib/Service/BinExt.php b/lib/Service/BinExt.php index adde550e..7c0e836d 100644 --- a/lib/Service/BinExt.php +++ b/lib/Service/BinExt.php @@ -32,6 +32,10 @@ class BinExt } if ($copy) { + if (empty($path)) { + throw new \Exception('binary path is empty (run occ maintenance:repair)'); + } + if (!copy($path, $target)) { throw new \Exception("failed to copy {$name} binary from {$path} to {$target}"); }