add more config to repair step

Signed-off-by: Varun Patil <varunpatil@ucla.edu>
pull/563/head
Varun Patil 2023-04-10 14:32:35 -07:00
parent 8cdfe0a97e
commit 312039deab
6 changed files with 94 additions and 17 deletions

View File

@ -35,18 +35,18 @@ class BinExt
} }
/** Detect the exiftool binary to use */ /** Detect the exiftool binary to use */
public static function detectExiftool(): void public static function detectExiftool()
{ {
if (!empty($path = Util::getSystemConfig('memories.exiftool'))) { if (!empty($path = Util::getSystemConfig('memories.exiftool'))) {
if (file_exists($path) && !is_executable($path)) { if (file_exists($path) && !is_executable($path)) {
chmod($path, 0755); @chmod($path, 0755);
} }
return; return $path;
} }
if (Util::getSystemConfig('memories.exiftool_no_local')) { if (Util::getSystemConfig('memories.exiftool_no_local')) {
return; return implode(' ', self::getExiftool());
} }
// Detect architecture // Detect architecture
@ -64,12 +64,72 @@ class BinExt
// make sure it is executable // make sure it is executable
if (file_exists($path)) { if (file_exists($path)) {
if (!is_executable($path)) { if (!is_executable($path)) {
chmod($path, 0755); @chmod($path, 0755);
} }
} else {
error_log("Exiftool binary not found: {$path}"); return $path;
Util::setSystemConfig('memories.exiftool_no_local', true);
} }
} }
Util::setSystemConfig('memories.exiftool_no_local', true);
return false;
}
/** Detect the go-vod binary to use */
public static function detectGoVod()
{
$goVodPath = Util::getSystemConfig('memories.vod.path');
if (empty($goVodPath) || !file_exists($goVodPath)) {
// Detect architecture
$arch = \OCA\Memories\Util::getArch();
$path = __DIR__."/../exiftool-bin/go-vod-{$arch}";
$goVodPath = realpath($path);
if (!$goVodPath) {
return false;
}
// Set config
Util::setSystemConfig('memories.vod.path', $goVodPath);
// Make executable
if (!is_executable($goVodPath)) {
@chmod($goVodPath, 0755);
}
}
return $goVodPath;
}
public static function detectFFmpeg()
{
$ffmpegPath = Util::getSystemConfig('memories.vod.ffmpeg');
$ffprobePath = Util::getSystemConfig('memories.vod.ffprobe');
if (empty($ffmpegPath) || !file_exists($ffmpegPath) || empty($ffprobePath) || !file_exists($ffprobePath)) {
// Use PATH
$ffmpegPath = shell_exec('which ffmpeg');
$ffprobePath = shell_exec('which ffprobe');
if (!$ffmpegPath || !$ffprobePath) {
return false;
}
// Trim
$ffmpegPath = trim($ffmpegPath);
$ffprobePath = trim($ffprobePath);
// Set config
Util::setSystemConfig('memories.vod.ffmpeg', $ffmpegPath);
Util::setSystemConfig('memories.vod.ffprobe', $ffprobePath);
}
// Check if executable
if (!is_executable($ffmpegPath) || !is_executable($ffprobePath)) {
return false;
}
return $ffmpegPath;
} }
} }

View File

@ -24,11 +24,28 @@ class Repair implements IRepairStep
public function run(IOutput $output): void public function run(IOutput $output): void
{ {
// detect exiftool binary // kill any instances of go-vod
\OCA\Memories\BinExt::detectExiftool();
// kill any instances of go-transcode and go-vod
\OCA\Memories\Util::pkill('go-transcode');
\OCA\Memories\Util::pkill('go-vod'); \OCA\Memories\Util::pkill('go-vod');
// detect exiftool
if ($path = \OCA\Memories\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()) {
$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()) {
$output->info("ffmpeg binary is configured: {$path}");
} else {
$output->warning('ffmpeg binary could not be configured');
}
} }
} }

View File

@ -308,7 +308,7 @@ class Util
// Check if the key is valid // Check if the key is valid
$defaults = self::systemConfigDefaults(); $defaults = self::systemConfigDefaults();
if (!\array_key_exists($key, $defaults)) { if (!\array_key_exists($key, $defaults)) {
throw new \InvalidArgumentException('Invalid system config key'); throw new \InvalidArgumentException("Invalid system config key: {$key}");
} }
// Check if the value has the correct type // Check if the value has the correct type

View File

@ -398,7 +398,7 @@ export default defineComponent({
}, },
async update(key: string, value = null) { async update(key: string, value = null) {
value ||= this[key]; value = value ?? this[key];
const setting = settings[key]; const setting = settings[key];
// Inversion // Inversion

View File

@ -94,7 +94,7 @@ import LinkIcon from "vue-material-design-icons/LinkVariant.vue";
import FileIcon from "vue-material-design-icons/File.vue"; import FileIcon from "vue-material-design-icons/File.vue";
// Is video transcoding enabled? // Is video transcoding enabled?
const config_vodDisable = loadState("memories", "vod_disable"); const config_vodDisable = loadState("memories", "vod_disable", true);
export default defineComponent({ export default defineComponent({
name: "ShareModal", name: "ShareModal",

View File

@ -23,7 +23,7 @@ type PsVideoEvent = PsEvent & {
content: VideoContent; content: VideoContent;
}; };
const config_vodDisable = loadState("memories", "vod_disable"); const config_vodDisable = loadState("memories", "vod_disable", true);
const config_video_default_quality = Number( const config_video_default_quality = Number(
loadState("memories", "video_default_quality", <string>"0") as string loadState("memories", "video_default_quality", <string>"0") as string