old-stable24
Varun Patil 2022-10-20 14:05:01 -07:00
parent 9ae7bd112d
commit 2c4f91e029
1 changed files with 22 additions and 22 deletions

View File

@ -10,13 +10,13 @@ use OCP\IConfig;
class Exif class Exif
{ {
private const EXIFTOOL_VER = '12.49';
/** Opened instance of exiftool when running in command mode */ /** Opened instance of exiftool when running in command mode */
private static $staticProc; private static $staticProc;
private static $staticPipes; private static $staticPipes;
private static $noStaticProc = false; private static $noStaticProc = false;
private const EXIFTOOL_VER = '12.49';
public static function closeStaticExiftoolProc() public static function closeStaticExiftoolProc()
{ {
try { try {
@ -399,59 +399,59 @@ class Exif
$noLocal = $config->getSystemValue($configKey.'_no_local', false); $noLocal = $config->getSystemValue($configKey.'_no_local', false);
// We know already where it is // We know already where it is
if (!empty($configPath) && \file_exists($configPath)) { if (!empty($configPath) && file_exists($configPath)) {
return $configPath; return $configPath;
} }
// Detect architecture // Detect architecture
$arch = null; $arch = null;
$uname = php_uname("m"); $uname = php_uname('m');
if (false !== stripos($uname, "aarch64") || false !== stripos($uname,"arm64")) { if (false !== stripos($uname, 'aarch64') || false !== stripos($uname, 'arm64')) {
$arch = "aarch64"; $arch = 'aarch64';
} else if (false !== stripos($uname, "x86_64") || false !== stripos($uname, "amd64")) { } elseif (false !== stripos($uname, 'x86_64') || false !== stripos($uname, 'amd64')) {
$arch = "amd64"; $arch = 'amd64';
} }
// Detect glibc or musl // Detect glibc or musl
$libc = null; $libc = null;
$ldd = shell_exec("ldd --version"); $ldd = shell_exec('ldd --version');
if (false !== stripos($ldd, "musl")) { if (false !== stripos($ldd, 'musl')) {
$libc = "musl"; $libc = 'musl';
} else if (false !== stripos($ldd, "glibc")) { } elseif (false !== stripos($ldd, 'glibc')) {
$libc = "glibc"; $libc = 'glibc';
} }
// Get static binary if available // Get static binary if available
if ($arch && $libc && !$noLocal) { if ($arch && $libc && !$noLocal) {
// get target file path // get target file path
$path = dirname(__FILE__) . "/../exiftool-bin/exiftool-$arch-$libc"; $path = __DIR__."/../exiftool-bin/exiftool-{$arch}-{$libc}";
// check if file exists // check if file exists
if (file_exists($path)) { if (file_exists($path)) {
// check if the version prints correctly // check if the version prints correctly
$ver = self::EXIFTOOL_VER; $ver = self::EXIFTOOL_VER;
$vero = shell_exec("$path -ver"); $vero = shell_exec("{$path} -ver");
if ($vero && false !== stripos(trim($vero), $ver)) { if ($vero && false !== stripos(trim($vero), $ver)) {
$out = trim($vero); $out = trim($vero);
print("Exiftool binary version check passed $out <==> $ver\n"); echo "Exiftool binary version check passed {$out} <==> {$ver}\n";
$config->setSystemValue($configKey, $path); $config->setSystemValue($configKey, $path);
return $path; return $path;
} else {
error_log("Exiftool version check failed $vero <==> $ver");
$config->setSystemValue($configKey.'_no_local', true);
} }
error_log("Exiftool version check failed {$vero} <==> {$ver}");
$config->setSystemValue($configKey.'_no_local', true);
} else { } else {
error_log("Exiftool not found: $path"); error_log("Exiftool not found: {$path}");
} }
} }
// Fallback to perl script // Fallback to perl script
$path = dirname(__FILE__) . "/../exiftool-bin/exiftool/exiftool"; $path = __DIR__.'/../exiftool-bin/exiftool/exiftool';
if (file_exists($path)) { if (file_exists($path)) {
return $path; return $path;
} }
error_log("Exiftool not found: $path"); error_log("Exiftool not found: {$path}");
// Fallback to system binary // Fallback to system binary
return 'exiftool'; return 'exiftool';