Update index.php

pull/13/head
qkqpttgf 2020-01-02 10:05:48 +08:00 committed by GitHub
parent 1330eed999
commit f2bc368dc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 9 deletions

View File

@ -149,7 +149,7 @@ function list_files($path)
if ( isset($files['folder']) || isset($files['file']) || isset($files['error']) ) { if ( isset($files['folder']) || isset($files['file']) || isset($files['error']) ) {
return $files; return $files;
} else { } else {
echo 'Error $files' . json_encode($files, JSON_PRETTY_PRINT); error_log( $files . ' Network Error<br>' );
$_SERVER['retry']++; $_SERVER['retry']++;
if ($_SERVER['retry'] < 3) { if ($_SERVER['retry'] < 3) {
return list_files($path); return list_files($path);
@ -468,17 +468,22 @@ function fetch_files($path = '/')
if (substr($url,-1)=='/') $url=substr($url,0,-1); if (substr($url,-1)=='/') $url=substr($url,0,-1);
} }
$url .= '?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime)'; $url .= '?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime)';
$files = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true); $arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']]);
// echo $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>'; if ($arr['stat']==200) {
if (isset($files['folder'])) { $files = json_decode($arr['body'], true);
if ($files['folder']['childCount']>200) { // echo $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
if (isset($files['folder'])) {
if ($files['folder']['childCount']>200) {
// files num > 200 , then get nextlink // files num > 200 , then get nextlink
$page = $_POST['pagenum']==''?1:$_POST['pagenum']; $page = $_POST['pagenum']==''?1:$_POST['pagenum'];
$files=fetch_files_children($files, $path, $page, $cache); $files=fetch_files_children($files, $path, $page, $cache);
} else { } else {
// files num < 200 , then cache // files num < 200 , then cache
$cache->save('path_' . $path, $files, 60); $cache->save('path_' . $path, $files, 60);
}
} }
} else {
$files = $arr['stat'];
} }
} }
return $files; return $files;