From 967c62c666d18acc6d3cb448586fec688f23d250 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 3 May 2024 12:12:17 -0700 Subject: [PATCH] repair: auto-fix system config types (#1168) Signed-off-by: Varun Patil --- lib/Migration/Repair.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/Migration/Repair.php b/lib/Migration/Repair.php index 29f6b8abf..71582eedc 100644 --- a/lib/Migration/Repair.php +++ b/lib/Migration/Repair.php @@ -21,9 +21,13 @@ public function getName(): string public function run(IOutput $output): void { - // Add missing indices AddMissingIndices::run($output); + $this->configureBinExt($output); + $this->fixSystemConfigTypes($output); + } + public function configureBinExt(IOutput $output): void + { // kill any instances of go-vod and exiftool BinExt::pkill(BinExt::getName('go-vod')); BinExt::pkill(BinExt::getName('exiftool')); @@ -49,4 +53,21 @@ public function run(IOutput $output): void $output->warning('ffmpeg binary could not be configured'); } } + + public function fixSystemConfigTypes(IOutput $output): void + { + // https://github.com/pulsejet/memories/issues/1168 + $intKeys = [ + 'preview_max_x', + 'preview_max_y', + 'jpeg_quality', + ]; + foreach ($intKeys as $key) { + $value = $this->config->getSystemValue($key, null); + if (null !== $value && !\is_int($value)) { + $output->info("Fixing system config value for {$key}"); + $this->config->setSystemValue($key, (int) $value ?: 2048); + } + } + } }