binext: catch missing exiftool error (fix #601)

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/653/head
Varun Patil 2023-04-24 12:42:54 -07:00
parent e5a958916e
commit 13341ebbd3
2 changed files with 17 additions and 5 deletions

View File

@ -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,7 +253,7 @@ class OtherController extends GenericApiController
/**
* Get the status of an executable.
*
* @param string $path Path to the 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
@ -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';
}

View File

@ -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}");
}