Append number to new updates with the same name instead of removal

This commit is contained in:
whatever127 2019-07-02 17:47:32 +02:00
parent c853ef74a4
commit 71ee499b4a
2 changed files with 25 additions and 19 deletions

View File

@ -169,7 +169,7 @@ function uupFetchUpd(
); );
} }
function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku = '48') { function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku) {
$updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo); $updateNumId = preg_replace('/<UpdateInfo><ID>|<\/ID>.*/i', '', $updateInfo);
$updates = preg_replace('/<Update>/', "\n<Update>", $out); $updates = preg_replace('/<Update>/', "\n<Update>", $out);
@ -234,6 +234,29 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
$updateString = $updateId.'_rev.'.$updateRev; $updateString = $updateId.'_rev.'.$updateRev;
} }
$ids = uupListIds();
if(!isset($ids['error'])) {
$ids = $ids['builds'];
$namesList = array();
foreach($ids as $val) {
$testName = $val['build'].' '.$val['title'].' '.$val['arch'];
if($val['uuid'] != $updateString) {
$namesList[$val['uuid']] = $testName;
}
}
$num = 1;
$buildName = $foundBuild.' '.$updateTitle.' '.$foundArch;
while(in_array($buildName, $namesList, true)) {
$num++;
$buildName = "$foundBuild $updateTitle ($num) $foundArch";
}
if($num > 1) $updateTitle = "$updateTitle ($num)";
}
consoleLogger("--- UPDATE INFORMATION ---"); consoleLogger("--- UPDATE INFORMATION ---");
consoleLogger("Title: ".$updateTitle); consoleLogger("Title: ".$updateTitle);
consoleLogger("Architecture: ".$foundArch); consoleLogger("Architecture: ".$foundArch);
@ -305,23 +328,6 @@ function parseFetchUpdate($updateInfo, $out, $arch, $ring, $flight, $build, $sku
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.' '.$foundArch;
foreach($ids as $val) {
$testName = $val['build'].' '.$val['title'].' '.$val['arch'];
if($buildName == $testName && $val['uuid'] != $updateString) {
unlink(realpath('fileinfo/'.$val['uuid'].'.json'));
if(file_exists('packs/'.$val['uuid'].'.json.gz')) {
unlink(realpath('packs/'.$val['uuid'].'.json.gz'));
}
consoleLogger('Removed superseded update: '.$val['uuid']);
}
}
}
return array( return array(
'updateId' => $updateString, 'updateId' => $updateString,
'updateTitle' => $updateTitle, 'updateTitle' => $updateTitle,

View File

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