From 496e015611bf63fdc451ef00b04d1eebcc1a3f93 Mon Sep 17 00:00:00 2001 From: mkuba50 Date: Tue, 10 Oct 2017 19:38:04 +0200 Subject: [PATCH] Update cache only when there are changes --- listid.php | 18 ++++++++++++++---- shared/main.php | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/listid.php b/listid.php index daba862..b0443ba 100644 --- a/listid.php +++ b/listid.php @@ -67,7 +67,10 @@ function uupListIds() { 'uuid' => $uuid, ); - $builds = array_merge($builds, array($build.$arch.$title.$uuid => $temp)); + $builds = array_merge( + $builds, + array($build.$arch.$title.$uuid => $temp) + ); } krsort($builds); @@ -81,9 +84,16 @@ function uupListIds() { consoleLogger('Done parsing database info.'); - if(!file_exists('cache')) mkdir('cache'); - $success = @file_put_contents('cache/fileinfo.json', json_encode($newDb)."\n"); - if(!$success) consoleLogger('Failed to update database cache.'); + if($newDb != $database) { + if(!file_exists('cache')) mkdir('cache'); + + $success = @file_put_contents( + 'cache/fileinfo.json', + json_encode($newDb)."\n" + ); + + if(!$success) consoleLogger('Failed to update database cache.'); + } return array( 'apiVersion' => uupApiVersion(), diff --git a/shared/main.php b/shared/main.php index c8279f7..cee7094 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.1.0'; + return '1.1.1'; } function uupApiPrintBrand() {