From 0752081d1522672926f972d0dc4a03c9defcbd55 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 3 Sep 2023 09:26:54 -0700 Subject: [PATCH] refactor: remove force option from getSysConfig Signed-off-by: Varun Patil --- lib/Controller/AdminController.php | 2 +- lib/Service/BinExt.php | 2 +- lib/SystemConfigDefault.php | 4 ++++ lib/Util.php | 11 ++++------- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index e488b5a8..d4b72cf8 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -133,7 +133,7 @@ class AdminController extends GenericApiController // Check for FFmpeg for preview generation $status['ffmpeg_preview'] = $this->getExecutableStatus( - Util::getSystemConfig('preview_ffmpeg_path', null, true) + Util::getSystemConfig('preview_ffmpeg_path') ?: trim(shell_exec('which ffmpeg') ?: ''), static fn ($p) => BinExt::testFFmpeg($p, 'ffmpeg'), ); diff --git a/lib/Service/BinExt.php b/lib/Service/BinExt.php index 92bb3e43..502e0283 100644 --- a/lib/Service/BinExt.php +++ b/lib/Service/BinExt.php @@ -165,7 +165,7 @@ class BinExt 'vaapi' => Util::getSystemConfig('memories.vod.vaapi'), 'vaapiLowPower' => Util::getSystemConfig('memories.vod.vaapi.low_power'), - 'nvenc' => Util::getSystemConfig('memories.vod.nvenc', false), + 'nvenc' => Util::getSystemConfig('memories.vod.nvenc'), 'nvencTemporalAQ' => Util::getSystemConfig('memories.vod.nvenc.temporal_aq'), 'nvencScale' => Util::getSystemConfig('memories.vod.nvenc.scale'), diff --git a/lib/SystemConfigDefault.php b/lib/SystemConfigDefault.php index 27a19d3f..331854c3 100644 --- a/lib/SystemConfigDefault.php +++ b/lib/SystemConfigDefault.php @@ -72,4 +72,8 @@ return [ 'preview_max_y' => 4096, 'preview_max_memory' => 128, 'preview_max_filesize_image' => 50, + 'preview_ffmpeg_path' => '', + + // Placeholders only; these are not touched by the app + 'instanceid' => 'default', ]; diff --git a/lib/Util.php b/lib/Util.php index f4318287..bea8d079 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -364,17 +364,14 @@ class Util * * @param string $key System config key * @param null|mixed $default Default value - * @param bool $force Do not check if the key is valid */ - public static function getSystemConfig(string $key, $default = null, bool $force = false) + public static function getSystemConfig(string $key, $default = null) { $config = \OC::$server->get(\OCP\IConfig::class); $defaults = self::systemConfigDefaults(); - if (!$force) { - if (!\array_key_exists($key, $defaults)) { - throw new \InvalidArgumentException("Invalid system config key: {$key}"); - } + if (!\array_key_exists($key, $defaults)) { + throw new \InvalidArgumentException("Invalid system config key: {$key}"); } return $config->getSystemValue($key, $default ?? $defaults[$key]); @@ -431,7 +428,7 @@ class Util */ public static function getInstanceId(): string { - return self::getSystemConfig('instanceid', 'default', true); + return self::getSystemConfig('instanceid'); } /**