try fix activityLimitReached

pull/276/head
qkqpttgf 2021-03-14 17:34:18 +08:00 committed by GitHub
parent 7b51e773f3
commit d5c456bc0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -514,11 +514,11 @@ class Onedrive {
} }
$api = $this->api_url . '/sites/root'; $api = $this->api_url . '/sites/root';
$arr = curl('GET', $api, '', [ 'Authorization' => 'Bearer ' . $this->access_token ]); $arr = $this->MSAPI('GET', $api);
$Tenant = json_decode($arr['body'], true)['webUrl']; $Tenant = json_decode($arr['body'], true)['webUrl'];
$api = $this->api_url . '/me/followedSites'; $api = $this->api_url . '/me/followedSites';
$arr = curl('GET', $api, '', [ 'Authorization' => 'Bearer ' . $this->access_token ]); $arr = $this->MSAPI('GET', $api);
if (!($arr['stat']==200||$arr['stat']==403||$arr['stat']==400||$arr['stat']==404)) return message($arr['stat'] . json_encode(json_decode($arr['body']), JSON_PRETTY_PRINT), 'Get followedSites', $arr['stat']); if (!($arr['stat']==200||$arr['stat']==403||$arr['stat']==400||$arr['stat']==404)) return message($arr['stat'] . json_encode(json_decode($arr['body']), JSON_PRETTY_PRINT), 'Get followedSites', $arr['stat']);
error_log1($arr['body']); error_log1($arr['body']);
$sites = json_decode($arr['body'], true)['value']; $sites = json_decode($arr['body'], true)['value'];
@ -812,7 +812,7 @@ class Onedrive {
$i=0; $i=0;
$response = []; $response = [];
while ($url!=''&&$response['stat']!=200&&$i<4) { while ($url!=''&&$response['stat']!=200&&$i<4) {
$response = curl('GET', $url, false, ['Authorization' => 'Bearer ' . $this->access_token]); $response = $this->MSAPI('GET', $url);
$i++; $i++;
} }
if ($response['stat']!=200) { if ($response['stat']!=200) {
@ -990,7 +990,11 @@ class Onedrive {
if ($response['stat']==429) { if ($response['stat']==429) {
$res = json_decode($response['body'], true); $res = json_decode($response['body'], true);
$retryAfter = $res['error']['retryAfterSeconds']; $retryAfter = $res['error']['retryAfterSeconds'];
setConfig(['activeLimit' => time()+$retryAfter], $this->disktag); $retryAfter_n = (int)$retryAfter;
if ($retryAfter_n>0) {
$tmp1['activeLimit'] = $retryAfter_n + time();
setConfig($tmp1, $this->disktag);
}
} }
curl_close($ch); curl_close($ch);
error_log1($response['stat'].' error_log1($response['stat'].'