diff --git a/fetchupd.php b/fetchupd.php index 315730c..75d6786 100644 --- a/fetchupd.php +++ b/fetchupd.php @@ -17,6 +17,7 @@ limitations under the License. require_once dirname(__FILE__).'/shared/main.php'; require_once dirname(__FILE__).'/shared/requests.php'; +require_once dirname(__FILE__).'/listid.php'; function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build = '16251') { uupApiPrintBrand(); @@ -89,7 +90,7 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build $fileWrite = 'NO_SAVE'; if(!file_exists('fileinfo/'.$updateId.'.json')) { 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'); $fileList = preg_replace('/|<\/Files>/', '', $fileList[0]); @@ -144,6 +145,20 @@ function uupFetchUpd($arch = 'amd64', $ring = 'WIF', $flight = 'Active', $build 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( 'apiVersion' => uupApiVersion(), 'updateId' => $updateId, diff --git a/shared/main.php b/shared/main.php index a39d5b3..4b0e5de 100644 --- a/shared/main.php +++ b/shared/main.php @@ -16,11 +16,16 @@ limitations under the License. */ function uupApiVersion() { - return '0.4.0-alpha'; + return '0.5.0-beta'; } 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) {