From 447cc7468ac697a9541d9b1370253c0ae4568078 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 15 Mar 2020 20:50:29 +0800 Subject: [PATCH] try to fix random jpg >200 --- function/common.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/function/common.php b/function/common.php index 9bca61c..cfd4fef 100644 --- a/function/common.php +++ b/function/common.php @@ -938,18 +938,15 @@ function fetch_files($path = '/') // echo $path . '
' . json_encode($files, JSON_PRETTY_PRINT) . '
'; 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']; - $files=fetch_files_children($files, $path1, $page); + if ($page>1) $files=fetch_files_children($files, $path1, $page); + $files['children'] = children_name($files['children']); } else { // files num < 200 , then cache - if (isset($files['children'])) { - $tmp = []; - foreach ($files['children'] as $file) { - $tmp[$file['name']] = $file; - } - $files['children'] = $tmp; - } + //if (isset($files['children'])) { + $files['children'] = children_name($files['children']); + //} savecache('path_' . $path, $files); } } @@ -965,6 +962,15 @@ function fetch_files($path = '/') return $files; } +function children_name($children) +{ + $tmp = []; + foreach ($children as $file) { + $tmp[$file['name']] = $file; + } + return $tmp; +} + function fetch_files_children($files, $path, $page) { $path1 = path_format($path);