forked from uup-dump/api
Add option to ignore files from fileinfo
This commit is contained in:
parent
d5769f635c
commit
9a80701470
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright 2017 UUP dump API authors
|
||||
Copyright 2022 UUP dump API authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -16,15 +16,40 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__).'/shared/main.php';
|
||||
require_once dirname(__FILE__).'/shared/cache.php';
|
||||
|
||||
function uupUpdateInfo($updateId, $onlyInfo = 0) {
|
||||
$info = @file_get_contents('fileinfo/'.$updateId.'.json');
|
||||
function uupApiPrivateGetFileinfo($updateId, $ignoreFiles) {
|
||||
$cached = false;
|
||||
|
||||
if(empty($info)) {
|
||||
return array('error' => 'UPDATE_INFORMATION_NOT_EXISTS');
|
||||
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;
|
||||
}
|
||||
|
||||
function uupUpdateInfo($updateId, $onlyInfo = 0, $ignoreFiles = false) {
|
||||
$info = uupApiPrivateGetFileinfo($updateId, $ignoreFiles);
|
||||
if($info === false) {
|
||||
return ['error' => 'UPDATE_INFORMATION_NOT_EXISTS'];
|
||||
}
|
||||
|
||||
$parsedInfo = uupParseUpdateInfo($info, $onlyInfo);
|
||||
if(isset($parsedInfo['error'])) {
|
||||
@ -39,7 +64,7 @@ function uupUpdateInfo($updateId, $onlyInfo = 0) {
|
||||
|
||||
function uupParseUpdateInfo($info, $onlyInfo = 0) {
|
||||
if(empty($info)) {
|
||||
return array('error' => 'UPDATE_INFORMATION_NOT_EXISTS');
|
||||
return ['error' => 'UPDATE_INFORMATION_NOT_EXISTS'];
|
||||
}
|
||||
|
||||
if($onlyInfo) {
|
||||
@ -57,4 +82,3 @@ function uupParseUpdateInfo($info, $onlyInfo = 0) {
|
||||
'info' => $returnInfo,
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user