refactor: move binext to service

Signed-off-by: Varun Patil <varunpatil@ucla.edu>
pull/579/head
Varun Patil 2023-04-14 16:02:13 -07:00
parent 3ada3d6510
commit 7245511bd2
6 changed files with 18 additions and 15 deletions

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace OCA\Memories\Command;
use OCA\Memories\BinExt;
use OCA\Memories\Db\TimelineWrite;
use OCA\Memories\Service;
use OCP\Files\IRootFolder;
@ -111,7 +110,7 @@ class Index extends Command
try {
// Use static exiftool process
\OCA\Memories\Exif::ensureStaticExiftoolProc();
if (!BinExt::testExiftool()) { // throws
if (!Service\BinExt::testExiftool()) { // throws
throw new \Exception('exiftool could not be executed or test failed');
}

View File

@ -24,8 +24,8 @@ declare(strict_types=1);
namespace OCA\Memories\Controller;
use OCA\Memories\AppInfo\Application;
use OCA\Memories\BinExt;
use OCA\Memories\Exceptions;
use OCA\Memories\Service\BinExt;
use OCA\Memories\Util;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;

View File

@ -23,9 +23,9 @@ declare(strict_types=1);
namespace OCA\Memories\Controller;
use OCA\Memories\BinExt;
use OCA\Memories\Exceptions;
use OCA\Memories\Exif;
use OCA\Memories\Service\BinExt;
use OCA\Memories\Util;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace OCA\Memories;
use OCA\Memories\AppInfo\Application;
use OCA\Memories\Service\BinExt;
use OCP\Files\File;
use OCP\IConfig;

View File

@ -4,7 +4,8 @@ declare(strict_types=1);
namespace OCA\Memories\Migration;
use OCA\Memories\BinExt;
use OCA\Memories\Db\AddMissingIndices;
use OCA\Memories\Service\BinExt;
use OCA\Memories\Util;
use OCP\IConfig;
use OCP\Migration\IOutput;
@ -27,28 +28,28 @@ class Repair implements IRepairStep
public function run(IOutput $output): void
{
// Add missing indices
\OCA\Memories\Db\AddMissingIndices::run();
AddMissingIndices::run();
// kill any instances of go-vod and exiftool
Util::pkill(BinExt::getName('go-vod'));
Util::pkill(BinExt::getName('exiftool'));
// detect exiftool
if ($path = \OCA\Memories\BinExt::detectExiftool()) {
if ($path = BinExt::detectExiftool()) {
$output->info("exiftool binary is configured: {$path}");
} else {
$output->warning('exiftool binary could not be configured');
}
// detect go-vod
if ($path = \OCA\Memories\BinExt::detectGoVod()) {
if ($path = BinExt::detectGoVod()) {
$output->info("go-vod binary is configured: {$path}");
} else {
$output->warning('go-vod binary could not be configured');
}
// detect ffmpeg
if ($path = \OCA\Memories\BinExt::detectFFmpeg()) {
if ($path = BinExt::detectFFmpeg()) {
$output->info("ffmpeg binary is configured: {$path}");
} else {
$output->warning('ffmpeg binary could not be configured');

View File

@ -1,6 +1,8 @@
<?php
namespace OCA\Memories;
namespace OCA\Memories\Service;
use OCA\Memories\Util;
class BinExt
{
@ -63,7 +65,7 @@ class BinExt
}
// Test with actual file
$file = realpath(__DIR__.'/../exiftest.jpg');
$file = realpath(__DIR__.'/../../exiftest.jpg');
if (!$file) {
throw new \Exception('Could not find EXIF test file');
}
@ -97,7 +99,7 @@ class BinExt
public static function getExiftool(): array
{
if (Util::getSystemConfig('memories.exiftool_no_local')) {
return ['perl', realpath(__DIR__.'/../exiftool-bin/exiftool/exiftool')];
return ['perl', realpath(__DIR__.'/../../exiftool-bin/exiftool/exiftool')];
}
return [self::getExiftoolPBin()];
@ -121,7 +123,7 @@ class BinExt
// Get static binary if available
if ($arch && $libc) {
// get target file path
$path = realpath(__DIR__."/../exiftool-bin/exiftool-{$arch}-{$libc}");
$path = realpath(__DIR__."/../../exiftool-bin/exiftool-{$arch}-{$libc}");
// Set config
Util::setSystemConfig('memories.exiftool', $path);
@ -284,7 +286,7 @@ class BinExt
}
// TODO: check data mount; ignoring the result of the file for now
$testfile = realpath(__DIR__.'/../exiftest.jpg');
$testfile = realpath(__DIR__.'/../../exiftest.jpg');
// Make request
$url = self::getGoVodUrl('test', $testfile, 'test');
@ -346,7 +348,7 @@ class BinExt
if (empty($goVodPath) || !file_exists($goVodPath)) {
// Detect architecture
$arch = \OCA\Memories\Util::getArch();
$path = __DIR__."/../exiftool-bin/go-vod-{$arch}";
$path = __DIR__."/../../exiftool-bin/go-vod-{$arch}";
$goVodPath = realpath($path);
if (!$goVodPath) {