From cdfd89180af6562ed4d32105884b1d23bd91b08b Mon Sep 17 00:00:00 2001 From: Tom Chiverton Date: Wed, 18 Sep 2024 17:31:05 +0100 Subject: [PATCH 1/2] Make update CLI take param for dir path --- update.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/update.php b/update.php index c8a54f6..ecd4d98 100644 --- a/update.php +++ b/update.php @@ -78,7 +78,7 @@ $flag = (int) getpost('flag'); -if (PHP_SAPI == 'cli') cliUpdate(); +if (PHP_SAPI == 'cli') cliUpdate($argv); elseif ($action == 'update') update($dir_to_update); elseif ($action == 'imageUpdate') imageUpdate($flag); elseif ($action == 'saveImage') saveImage($flag); @@ -91,17 +91,17 @@ // +------------------------------------------------------------------------+ // | CLI Update wrapper | // +------------------------------------------------------------------------+ -function cliUpdate() { +function cliUpdate($argv_) { global $cfg, $db, $lastGenre_id, $getID3, $dirsCounter, $filesCounter, $curFilesCounter, $curDirsCounter, $last_update, $file; $cfg['cli_update'] = true; cliLog( "CLI update of " . $cfg['media_dir'] ); - echo ("Update started\n"); - echo ("Update in progress...\n"); + echo ("Update started\n"); + echo ("Update in progress...\n"); - update_impl( $cfg['media_dir'] ); + update_impl( $argv_[0] ); } From c7c0a491a8537081333be15cb67ae20a2dd4a66f Mon Sep 17 00:00:00 2001 From: Tom Chiverton Date: Wed, 18 Sep 2024 17:39:25 +0100 Subject: [PATCH 2/2] Add exception handler skeleton --- update.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/update.php b/update.php index ecd4d98..7b3e487 100644 --- a/update.php +++ b/update.php @@ -96,12 +96,16 @@ function cliUpdate($argv_) { $cfg['cli_update'] = true; - cliLog( "CLI update of " . $cfg['media_dir'] ); + cliLog( "CLI update of " . $argv_[1] ); echo ("Update started\n"); echo ("Update in progress...\n"); - - update_impl( $argv_[0] ); + + try { + update_impl( $argv_[1] ); + } catch (Exception $e) { + echo ("Update error") + } }