Merge pull request #21 from eraseyourknees/master

1.34.0
This commit is contained in:
eraseyourknees 2022-08-28 14:54:22 +02:00 committed by GitHub
commit 7011b1ead2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 11 deletions

View File

@ -353,6 +353,7 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
if($success) {
consoleLogger('Successfully written build information to the disk.');
$fileWrite = 'INFO_WRITTEN';
uupApiPrivateInvalidateFileinfoCache();
} else {
consoleLogger('An error has occured while writing the information to the disk.');
}

View File

@ -16,11 +16,18 @@ limitations under the License.
*/
require_once dirname(__FILE__).'/shared/main.php';
require_once dirname(__FILE__).'/shared/cache.php';
function uupListIds($search = null, $sortByDate = 0) {
uupApiPrintBrand();
function uupApiPrivateInvalidateFileinfoCache() {
$cache1 = new UupDumpCache('listid-0', false);
$cache2 = new UupDumpCache('listid-1', false);
if(!file_exists('fileinfo')) return array('error' => 'NO_FILEINFO_DIR');
$cache1->delete();
$cache2->delete();
}
function uupApiPrivateGetFromFileinfo($sortByDate = 0) {
if(!file_exists('fileinfo')) return false;
$files = scandir('fileinfo');
$files = preg_grep('/\.json$/', $files);
@ -105,12 +112,7 @@ function uupListIds($search = null, $sortByDate = 0) {
$builds[$tmp.$arch.$title.$uuid] = $temp;
}
if(empty($buildAssoc)) {
return array(
'apiVersion' => uupApiVersion(),
'builds' => array(),
);
}
if(empty($buildAssoc)) return [];
krsort($buildAssoc);
$buildsNew = array();
@ -141,7 +143,27 @@ function uupListIds($search = null, $sortByDate = 0) {
if(!$success) consoleLogger('Failed to update database cache.');
}
if($search) {
return $builds;
}
function uupListIds($search = null, $sortByDate = 0) {
uupApiPrintBrand();
$sortByDate = $sortByDate ? 1 : 0;
$res = "listid-$sortByDate";
$cache = new UupDumpCache($res, false);
$builds = $cache->get();
$cached = ($builds !== false);
if(!$cached) {
$builds = uupApiPrivateGetFromFileinfo($sortByDate);
if($builds === false) return ['error' => 'NO_FILEINFO_DIR'];
$cache->put($builds, 60);
}
if($search != null) {
if(!preg_match('/^regex:/', $search)) {
$searchSafe = preg_quote($search, '/');

View File

@ -16,7 +16,7 @@ limitations under the License.
*/
function uupApiVersion() {
return '1.33.0';
return '1.34.0';
}
require_once dirname(__FILE__).'/auths.php';