Save cache only after successful retrieval, better token generation

This commit is contained in:
whatever127
2019-08-20 18:09:40 +02:00
parent c5c6c47f15
commit 78642059cc
19 changed files with 19 additions and 17 deletions

24
get.php
View File

@ -273,19 +273,6 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests) {
$postData = composeFileGetRequest($updateId, uupDevice(), $info, $rev);
$out = sendWuPostRequest('https://fe3cr.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured', $postData);
consoleLogger('Information has been successfully fetched.');
if($cacheRequests == 1) {
$cache = array(
'expires' => time()+90,
'content' => $out,
'fetchTime' => $fetchTime,
);
if(!file_exists('cache')) mkdir('cache');
@file_put_contents('cache/'.$cacheHash.'.json.gz', gzencode(json_encode($cache)."\n"));
unset($cache);
}
}
consoleLogger('Parsing information...');
@ -365,6 +352,17 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests) {
}
}
if($cacheRequests == 1) {
$cache = array(
'expires' => time()+90,
'content' => $out,
'fetchTime' => $fetchTime,
);
if(!file_exists('cache')) mkdir('cache');
@file_put_contents('cache/'.$cacheHash.'.json.gz', gzencode(json_encode($cache)."\n"));
}
return $files;
}