Merge pull request #44 from qkqpttgf/master

try to fix random jpg >200
This commit is contained in:
Mr.Lin
2020-03-15 22:40:58 +08:00
committed by GitHub
+15 -9
View File
@@ -938,18 +938,15 @@ function fetch_files($path = '/')
// echo $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>'; // echo $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
if (isset($files['folder'])) { if (isset($files['folder'])) {
if ($files['folder']['childCount']>200) { 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, $path1, $page); if ($page>1) $files=fetch_files_children($files, $path1, $page);
$files['children'] = children_name($files['children']);
} else { } else {
// files num < 200 , then cache // files num < 200 , then cache
if (isset($files['children'])) { //if (isset($files['children'])) {
$tmp = []; $files['children'] = children_name($files['children']);
foreach ($files['children'] as $file) { //}
$tmp[$file['name']] = $file;
}
$files['children'] = $tmp;
}
savecache('path_' . $path, $files); savecache('path_' . $path, $files);
} }
} }
@@ -965,6 +962,15 @@ function fetch_files($path = '/')
return $files; return $files;
} }
function children_name($children)
{
$tmp = [];
foreach ($children as $file) {
$tmp[$file['name']] = $file;
}
return $tmp;
}
function fetch_files_children($files, $path, $page) function fetch_files_children($files, $path, $page)
{ {
$path1 = path_format($path); $path1 = path_format($path);