refactor: move binext to service
Signed-off-by: Varun Patil <varunpatil@ucla.edu>pull/579/head
parent
3ada3d6510
commit
7245511bd2
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Memories\Command;
|
namespace OCA\Memories\Command;
|
||||||
|
|
||||||
use OCA\Memories\BinExt;
|
|
||||||
use OCA\Memories\Db\TimelineWrite;
|
use OCA\Memories\Db\TimelineWrite;
|
||||||
use OCA\Memories\Service;
|
use OCA\Memories\Service;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
|
@ -111,7 +110,7 @@ class Index extends Command
|
||||||
try {
|
try {
|
||||||
// Use static exiftool process
|
// Use static exiftool process
|
||||||
\OCA\Memories\Exif::ensureStaticExiftoolProc();
|
\OCA\Memories\Exif::ensureStaticExiftoolProc();
|
||||||
if (!BinExt::testExiftool()) { // throws
|
if (!Service\BinExt::testExiftool()) { // throws
|
||||||
throw new \Exception('exiftool could not be executed or test failed');
|
throw new \Exception('exiftool could not be executed or test failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||||
namespace OCA\Memories\Controller;
|
namespace OCA\Memories\Controller;
|
||||||
|
|
||||||
use OCA\Memories\AppInfo\Application;
|
use OCA\Memories\AppInfo\Application;
|
||||||
use OCA\Memories\BinExt;
|
|
||||||
use OCA\Memories\Exceptions;
|
use OCA\Memories\Exceptions;
|
||||||
|
use OCA\Memories\Service\BinExt;
|
||||||
use OCA\Memories\Util;
|
use OCA\Memories\Util;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
|
|
@ -23,9 +23,9 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Memories\Controller;
|
namespace OCA\Memories\Controller;
|
||||||
|
|
||||||
use OCA\Memories\BinExt;
|
|
||||||
use OCA\Memories\Exceptions;
|
use OCA\Memories\Exceptions;
|
||||||
use OCA\Memories\Exif;
|
use OCA\Memories\Exif;
|
||||||
|
use OCA\Memories\Service\BinExt;
|
||||||
use OCA\Memories\Util;
|
use OCA\Memories\Util;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataDisplayResponse;
|
use OCP\AppFramework\Http\DataDisplayResponse;
|
||||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||||
namespace OCA\Memories;
|
namespace OCA\Memories;
|
||||||
|
|
||||||
use OCA\Memories\AppInfo\Application;
|
use OCA\Memories\AppInfo\Application;
|
||||||
|
use OCA\Memories\Service\BinExt;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Memories\Migration;
|
namespace OCA\Memories\Migration;
|
||||||
|
|
||||||
use OCA\Memories\BinExt;
|
use OCA\Memories\Db\AddMissingIndices;
|
||||||
|
use OCA\Memories\Service\BinExt;
|
||||||
use OCA\Memories\Util;
|
use OCA\Memories\Util;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\Migration\IOutput;
|
use OCP\Migration\IOutput;
|
||||||
|
@ -27,28 +28,28 @@ class Repair implements IRepairStep
|
||||||
public function run(IOutput $output): void
|
public function run(IOutput $output): void
|
||||||
{
|
{
|
||||||
// Add missing indices
|
// Add missing indices
|
||||||
\OCA\Memories\Db\AddMissingIndices::run();
|
AddMissingIndices::run();
|
||||||
|
|
||||||
// kill any instances of go-vod and exiftool
|
// kill any instances of go-vod and exiftool
|
||||||
Util::pkill(BinExt::getName('go-vod'));
|
Util::pkill(BinExt::getName('go-vod'));
|
||||||
Util::pkill(BinExt::getName('exiftool'));
|
Util::pkill(BinExt::getName('exiftool'));
|
||||||
|
|
||||||
// detect exiftool
|
// detect exiftool
|
||||||
if ($path = \OCA\Memories\BinExt::detectExiftool()) {
|
if ($path = BinExt::detectExiftool()) {
|
||||||
$output->info("exiftool binary is configured: {$path}");
|
$output->info("exiftool binary is configured: {$path}");
|
||||||
} else {
|
} else {
|
||||||
$output->warning('exiftool binary could not be configured');
|
$output->warning('exiftool binary could not be configured');
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect go-vod
|
// detect go-vod
|
||||||
if ($path = \OCA\Memories\BinExt::detectGoVod()) {
|
if ($path = BinExt::detectGoVod()) {
|
||||||
$output->info("go-vod binary is configured: {$path}");
|
$output->info("go-vod binary is configured: {$path}");
|
||||||
} else {
|
} else {
|
||||||
$output->warning('go-vod binary could not be configured');
|
$output->warning('go-vod binary could not be configured');
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect ffmpeg
|
// detect ffmpeg
|
||||||
if ($path = \OCA\Memories\BinExt::detectFFmpeg()) {
|
if ($path = BinExt::detectFFmpeg()) {
|
||||||
$output->info("ffmpeg binary is configured: {$path}");
|
$output->info("ffmpeg binary is configured: {$path}");
|
||||||
} else {
|
} else {
|
||||||
$output->warning('ffmpeg binary could not be configured');
|
$output->warning('ffmpeg binary could not be configured');
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace OCA\Memories;
|
namespace OCA\Memories\Service;
|
||||||
|
|
||||||
|
use OCA\Memories\Util;
|
||||||
|
|
||||||
class BinExt
|
class BinExt
|
||||||
{
|
{
|
||||||
|
@ -63,7 +65,7 @@ class BinExt
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test with actual file
|
// Test with actual file
|
||||||
$file = realpath(__DIR__.'/../exiftest.jpg');
|
$file = realpath(__DIR__.'/../../exiftest.jpg');
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
throw new \Exception('Could not find EXIF test file');
|
throw new \Exception('Could not find EXIF test file');
|
||||||
}
|
}
|
||||||
|
@ -97,7 +99,7 @@ class BinExt
|
||||||
public static function getExiftool(): array
|
public static function getExiftool(): array
|
||||||
{
|
{
|
||||||
if (Util::getSystemConfig('memories.exiftool_no_local')) {
|
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()];
|
return [self::getExiftoolPBin()];
|
||||||
|
@ -121,7 +123,7 @@ class BinExt
|
||||||
// Get static binary if available
|
// Get static binary if available
|
||||||
if ($arch && $libc) {
|
if ($arch && $libc) {
|
||||||
// get target file path
|
// get target file path
|
||||||
$path = realpath(__DIR__."/../exiftool-bin/exiftool-{$arch}-{$libc}");
|
$path = realpath(__DIR__."/../../exiftool-bin/exiftool-{$arch}-{$libc}");
|
||||||
|
|
||||||
// Set config
|
// Set config
|
||||||
Util::setSystemConfig('memories.exiftool', $path);
|
Util::setSystemConfig('memories.exiftool', $path);
|
||||||
|
@ -284,7 +286,7 @@ class BinExt
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check data mount; ignoring the result of the file for now
|
// TODO: check data mount; ignoring the result of the file for now
|
||||||
$testfile = realpath(__DIR__.'/../exiftest.jpg');
|
$testfile = realpath(__DIR__.'/../../exiftest.jpg');
|
||||||
|
|
||||||
// Make request
|
// Make request
|
||||||
$url = self::getGoVodUrl('test', $testfile, 'test');
|
$url = self::getGoVodUrl('test', $testfile, 'test');
|
||||||
|
@ -346,7 +348,7 @@ class BinExt
|
||||||
if (empty($goVodPath) || !file_exists($goVodPath)) {
|
if (empty($goVodPath) || !file_exists($goVodPath)) {
|
||||||
// Detect architecture
|
// Detect architecture
|
||||||
$arch = \OCA\Memories\Util::getArch();
|
$arch = \OCA\Memories\Util::getArch();
|
||||||
$path = __DIR__."/../exiftool-bin/go-vod-{$arch}";
|
$path = __DIR__."/../../exiftool-bin/go-vod-{$arch}";
|
||||||
$goVodPath = realpath($path);
|
$goVodPath = realpath($path);
|
||||||
|
|
||||||
if (!$goVodPath) {
|
if (!$goVodPath) {
|
Loading…
Reference in New Issue