From 6d5f3a80f9c9d07e1e95b2e85a695e9a64febb8d Mon Sep 17 00:00:00 2001 From: eraseyourknees <112027564+eraseyourknees@users.noreply.github.com> Date: Sun, 11 Sep 2022 03:46:54 +0200 Subject: [PATCH 1/9] Move fileinfo cache to fileinfo directory --- listid.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/listid.php b/listid.php index c23f3b1..661879c 100644 --- a/listid.php +++ b/listid.php @@ -34,7 +34,7 @@ function uupApiPrivateGetFromFileinfo($sortByDate = 0) { consoleLogger('Parsing database info...'); - $cacheFile = 'cache/fileinfo_v2.json'; + $cacheFile = 'fileinfo/?cache.json'; $cacheV2Version = 1; $database = @file_get_contents($cacheFile); @@ -57,7 +57,9 @@ function uupApiPrivateGetFromFileinfo($sortByDate = 0) { $newDb = array(); $builds = array(); foreach($files as $file) { - if($file == '.' || $file == '..') continue; + if($file == '.' || $file == '..' || $file == '?cache.json') + continue; + $uuid = preg_replace('/\.json$/', '', $file); if(!isset($database[$uuid])) { From 54b605c1d4629dd15a4a23b9861d3e31b2f000be Mon Sep 17 00:00:00 2001 From: eraseyourknees <112027564+eraseyourknees@users.noreply.github.com> Date: Sun, 11 Sep 2022 03:47:20 +0200 Subject: [PATCH 2/9] 1.37.0 --- shared/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/main.php b/shared/main.php index 96ba75b..0ea4ef2 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.36.0'; + return '1.37.0'; } require_once dirname(__FILE__).'/auths.php'; From 8894bd9cc0545dec2e96d7d4680a38340c63e43c Mon Sep 17 00:00:00 2001 From: eraseyourknees <112027564+eraseyourknees@users.noreply.github.com> Date: Tue, 13 Sep 2022 23:40:03 +0200 Subject: [PATCH 3/9] Add helper functions for json files --- shared/main.php | 2 +- shared/utils.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/shared/main.php b/shared/main.php index 0ea4ef2..ecebfe2 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.37.0'; + return '1.38.0-dev'; } require_once dirname(__FILE__).'/auths.php'; diff --git a/shared/utils.php b/shared/utils.php index 6a78915..8c9c1cb 100644 --- a/shared/utils.php +++ b/shared/utils.php @@ -166,3 +166,16 @@ function uupApiFixDownloadLink($link) { $link ); } + +function uupApiReadJson($path) { + $data = @file_get_contents($path); + + if(empty($data)) + return false; + + return json_decode($data, true); +} + +function uupApiWriteJson($path, $data) { + return file_put_contents($path, json_encode($data)."\n"); +} From 16b3bc786dc258cff8f3347f66dffc9f56b48cf0 Mon Sep 17 00:00:00 2001 From: eraseyourknees <112027564+eraseyourknees@users.noreply.github.com> Date: Tue, 13 Sep 2022 23:40:18 +0200 Subject: [PATCH 4/9] Add new fileinfo database support functions --- shared/fileinfo.php | 94 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 shared/fileinfo.php diff --git a/shared/fileinfo.php b/shared/fileinfo.php new file mode 100644 index 0000000..acb1141 --- /dev/null +++ b/shared/fileinfo.php @@ -0,0 +1,94 @@ + Date: Tue, 13 Sep 2022 23:41:43 +0200 Subject: [PATCH 5/9] fetchupd.php: Adjust for the new fileinfo database --- fetchupd.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fetchupd.php b/fetchupd.php index 8656caf..69fa50a 100644 --- a/fetchupd.php +++ b/fetchupd.php @@ -18,6 +18,7 @@ limitations under the License. require_once dirname(__FILE__).'/shared/main.php'; require_once dirname(__FILE__).'/shared/requests.php'; require_once dirname(__FILE__).'/shared/cache.php'; +require_once dirname(__FILE__).'/shared/fileinfo.php'; require_once dirname(__FILE__).'/listid.php'; function uupFetchUpd( @@ -288,10 +289,9 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku } $fileWrite = 'NO_SAVE'; - if(!file_exists('fileinfo/'.$updateString.'.json')) { + if(!uupApiFileInfoExists($updateId)) { consoleLogger('WARNING: This build is NOT in the database. It will be saved now.'); consoleLogger('Parsing information to write...'); - if(!file_exists('fileinfo')) mkdir('fileinfo'); $fileList = preg_replace('/|<\/Files>/', '', $fileList[0]); preg_match_all('//', $fileList, $fileList); @@ -349,7 +349,7 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku consoleLogger('Successfully parsed the information.'); consoleLogger('Writing new build information to the disk...'); - $success = file_put_contents('fileinfo/'.$updateString.'.json', json_encode($temp)."\n"); + $success = uupApiWriteFileinfo($updateString, $temp); if($success) { consoleLogger('Successfully written build information to the disk.'); $fileWrite = 'INFO_WRITTEN'; From 76092ff092b7d1c966dca876d45d4dde0db25c4f Mon Sep 17 00:00:00 2001 From: eraseyourknees <112027564+eraseyourknees@users.noreply.github.com> Date: Tue, 13 Sep 2022 23:41:50 +0200 Subject: [PATCH 6/9] get.php: Adjust for the new fileinfo database --- get.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/get.php b/get.php index 596de3d..1dea2c5 100644 --- a/get.php +++ b/get.php @@ -19,6 +19,7 @@ require_once dirname(__FILE__).'/shared/main.php'; require_once dirname(__FILE__).'/shared/requests.php'; require_once dirname(__FILE__).'/shared/packs.php'; require_once dirname(__FILE__).'/shared/cache.php'; +require_once dirname(__FILE__).'/shared/fileinfo.php'; /* $updateId = Update Identifier @@ -43,10 +44,10 @@ function uupGetFiles( } if(!uupApiCheckUpdateId($updateId)) { - return array('error' => 'INCORRECT_ID'); + return array('error' => 'INCORRECT_ID'); } - $info = @file_get_contents('fileinfo/'.$updateId.'.json'); + $info = uupApiReadFileinfo($updateId); if(empty($info)) { $info = array( 'ring' => 'WIF', @@ -56,8 +57,6 @@ function uupGetFiles( 'sku' => '48', 'files' => array(), ); - } else { - $info = json_decode($info, true); } if(isset($info['build'])) { From 0d06ee36f51c8efac710b89b7196bdcc69b8d148 Mon Sep 17 00:00:00 2001 From: eraseyourknees <112027564+eraseyourknees@users.noreply.github.com> Date: Tue, 13 Sep 2022 23:41:56 +0200 Subject: [PATCH 7/9] listid.php: Adjust for the new fileinfo database --- listid.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/listid.php b/listid.php index 661879c..970ff76 100644 --- a/listid.php +++ b/listid.php @@ -17,6 +17,7 @@ limitations under the License. require_once dirname(__FILE__).'/shared/main.php'; require_once dirname(__FILE__).'/shared/cache.php'; +require_once dirname(__FILE__).'/shared/fileinfo.php'; function uupApiPrivateInvalidateFileinfoCache() { $cache1 = new UupDumpCache('listid-0', false); @@ -27,18 +28,19 @@ function uupApiPrivateInvalidateFileinfoCache() { } function uupApiPrivateGetFromFileinfo($sortByDate = 0) { - if(!file_exists('fileinfo')) return false; + $dirs = uupApiGetFileinfoDirs(); + $fileinfo = $dirs['fileinfoData']; + $fileinfoRoot = $dirs['fileinfo']; - $files = scandir('fileinfo'); + $files = scandir($fileinfo); $files = preg_grep('/\.json$/', $files); consoleLogger('Parsing database info...'); - $cacheFile = 'fileinfo/?cache.json'; + $cacheFile = $fileinfoRoot.'/cache.json'; $cacheV2Version = 1; - $database = @file_get_contents($cacheFile); - $database = json_decode($database, true); + $database = uupApiReadJson($cacheFile); if(isset($database['version'])) { $version = $database['version']; @@ -57,14 +59,13 @@ function uupApiPrivateGetFromFileinfo($sortByDate = 0) { $newDb = array(); $builds = array(); foreach($files as $file) { - if($file == '.' || $file == '..' || $file == '?cache.json') + if($file == '.' || $file == '..') continue; $uuid = preg_replace('/\.json$/', '', $file); if(!isset($database[$uuid])) { - $info = @file_get_contents('fileinfo/'.$file); - $info = json_decode($info, true); + $info = uupApiReadFileinfoMeta($uuid); $title = isset($info['title']) ? $info['title'] : 'UNKNOWN'; $build = isset($info['build']) ? $info['build'] : 'UNKNOWN'; From 6831bb17e904170bdbcc28887840f2a171cb284d Mon Sep 17 00:00:00 2001 From: eraseyourknees <112027564+eraseyourknees@users.noreply.github.com> Date: Tue, 13 Sep 2022 23:42:12 +0200 Subject: [PATCH 8/9] updateinfo.php: Adjust for the new fileinfo db --- updateinfo.php | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/updateinfo.php b/updateinfo.php index cd51183..60e6fc5 100644 --- a/updateinfo.php +++ b/updateinfo.php @@ -17,36 +17,10 @@ limitations under the License. require_once dirname(__FILE__).'/shared/main.php'; require_once dirname(__FILE__).'/shared/cache.php'; - -function uupApiPrivateGetFileinfo($updateId, $ignoreFiles) { - $cached = false; - - if($ignoreFiles) { - $res = "fileinfo-fileless-$updateId"; - $cache = new UupDumpCache($res, false); - $info = $cache->get(); - $cached = ($info !== false); - } - - if(!$cached) { - $info = @file_get_contents('fileinfo/'.$updateId.'.json'); - if(empty($info)) return false; - $info = json_decode($info, true); - } - - if($ignoreFiles) { - if(isset($info['files'])) unset($info['files']); - - if(!$cached) { - $cache->put($info, false); - } - } - - return $info; -} +require_once dirname(__FILE__).'/shared/fileinfo.php'; function uupUpdateInfo($updateId, $onlyInfo = 0, $ignoreFiles = false) { - $info = uupApiPrivateGetFileinfo($updateId, $ignoreFiles); + $info = uupApiReadFileinfo($updateId, $ignoreFiles); if($info === false) { return ['error' => 'UPDATE_INFORMATION_NOT_EXISTS']; } From 541f8d95152c8b51d8e5c1aa91a0006139ebf98e Mon Sep 17 00:00:00 2001 From: eraseyourknees <112027564+eraseyourknees@users.noreply.github.com> Date: Tue, 13 Sep 2022 23:59:43 +0200 Subject: [PATCH 9/9] 1.38.0 --- shared/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/main.php b/shared/main.php index ecebfe2..1bb826c 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,7 +16,7 @@ limitations under the License. */ function uupApiVersion() { - return '1.38.0-dev'; + return '1.38.0'; } require_once dirname(__FILE__).'/auths.php';