Implemented superseded update removal to fetchupd.php

This commit is contained in:
mkuba50 2017-09-30 16:38:26 +02:00
parent 03727b01ce
commit 901414dcd4
2 changed files with 23 additions and 3 deletions

View File

@ -17,6 +17,7 @@ limitations under the License.
require_once dirname(__FILE__).'/shared/main.php'; require_once dirname(__FILE__).'/shared/main.php';
require_once dirname(__FILE__).'/shared/requests.php'; require_once dirname(__FILE__).'/shared/requests.php';
require_once dirname(__FILE__).'/listid.php';
function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build = '16251') { function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build = '16251') {
uupApiPrintBrand(); uupApiPrintBrand();
@ -89,7 +90,7 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build
$fileWrite = 'NO_SAVE'; $fileWrite = 'NO_SAVE';
if(!file_exists('fileinfo/'.$updateId.'.json')) { if(!file_exists('fileinfo/'.$updateId.'.json')) {
consoleLogger('WARNING: This build is NOT in the database. It will be saved now.'); consoleLogger('WARNING: This build is NOT in the database. It will be saved now.');
consoleLogger('Parsing information to write'); consoleLogger('Parsing information to write...');
if(!file_exists('fileinfo')) mkdir('fileinfo'); if(!file_exists('fileinfo')) mkdir('fileinfo');
$fileList = preg_replace('/<Files>|<\/Files>/', '', $fileList[0]); $fileList = preg_replace('/<Files>|<\/Files>/', '', $fileList[0]);
@ -144,6 +145,20 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build
consoleLogger('This build already exists in the database.'); consoleLogger('This build already exists in the database.');
} }
$ids = uupListIds();
if(!isset($ids['error'])) {
$ids = $ids['builds'];
$buildName = $foundBuild.' '.$updateTitle.' '.$arch;
foreach($ids as $val) {
$testName = $val['build'].' '.$val['title'].' '.$val['arch'];
if($buildName == $testName && $val['uuid'] != $updateId) {
unlink(realpath('fileinfo/'.$val['uuid'].'.json'));
consoleLogger('Removed superseded update: '.$val['uuid']);
}
}
}
return array( return array(
'apiVersion' => uupApiVersion(), 'apiVersion' => uupApiVersion(),
'updateId' => $updateId, 'updateId' => $updateId,

View File

@ -16,11 +16,16 @@ limitations under the License.
*/ */
function uupApiVersion() { function uupApiVersion() {
return '0.4.0-alpha'; return '0.5.0-beta';
} }
function uupApiPrintBrand() { function uupApiPrintBrand() {
consoleLogger('UUP dump API v'.uupApiVersion()); global $uupApiBrandPrinted;
if(!isset($uupApiBrandPrinted)) {
consoleLogger('UUP dump API v'.uupApiVersion());
$uupApiBrandPrinted = 1;
}
} }
function randStr($length = 4) { function randStr($length = 4) {