From 8798bf27cfcf483fd565c30291e09ee1aeb9c12e Mon Sep 17 00:00:00 2001
From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com>
Date: Sun, 22 Mar 2020 19:32:42 +0800
Subject: [PATCH 1/2] try to fix cache bug
---
function/common.php | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/function/common.php b/function/common.php
index 2a9bd45..5541bc7 100644
--- a/function/common.php
+++ b/function/common.php
@@ -291,6 +291,7 @@ function encode_str_replace($str)
function gethiddenpass($path,$passfile)
{
$path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
$password=getcache('path_' . $path1 . '/?password');
if ($password=='') {
$ispassfile = fetch_files(path_format($path . '/' . urlencode($passfile)));
@@ -456,7 +457,8 @@ function get_thumbnails_url($path = '/')
{
$path1 = path_format($path);
$path = path_format($_SERVER['list_path'] . path_format($path));
- $thumb_url = getcache($path);
+ if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
+ $thumb_url = getcache('thumb_'.$path);
if ($thumb_url!='') return output($thumb_url);
$url = $_SERVER['api_url'];
if ($path !== '/') {
@@ -466,7 +468,7 @@ function get_thumbnails_url($path = '/')
$url .= ':/thumbnails/0/medium';
$files = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
if (isset($files['url'])) {
- savecache($path, $files['url']);
+ savecache('thumb_'.$path, $files['url']);
return output($files['url']);
}
return output('', 404);
@@ -595,6 +597,7 @@ function main($path)
error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
$tmp = MSAPI('DELETE',path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . spurlencode($_GET['filename']) ),'',$_SERVER['access_token']);
$path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
savecache('path_' . $path1, json_decode('{}',true), 1);
return output($tmp['body'],$tmp['stat']);
}
@@ -615,6 +618,7 @@ function main($path)
$tmp['body'] = json_encode($tmpbody);
}
$path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
savecache('path_' . $path1, json_decode('{}',true), 1);
return output($tmp['body'],$tmp['stat']);
}
@@ -624,6 +628,7 @@ function main($path)
$tmp = adminoperate($path);
if ($tmp['statusCode'] > 0) {
$path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
savecache('path_' . $path1, json_decode('{}',true), 1);
return $tmp;
}
@@ -771,6 +776,7 @@ function adminoperate($path)
//savecache('path_' . $path1, json_decode('{}',true), 1);
if ($_GET['move_folder'] == '/../') $path2 = path_format( substr($path1, 0, strrpos($path1, '/')) . '/' );
else $path2 = path_format( $path1 . '/' . $_GET['move_folder'] . '/' );
+ if ($path2!='/'&&substr($path2,-1)=='/') $path2=substr($path2,0,-1);
savecache('path_' . $path2, json_decode('{}',true), 1);
return output($result['body'], $result['stat']);
} else {
@@ -842,6 +848,7 @@ function adminoperate($path)
}
if (isset($_GET['RefreshCache'])) {
$path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
savecache('path_' . $path1 . '/?password', '', 1);
return message('', getconstStr('RefreshCache'), 302);
}
@@ -944,6 +951,7 @@ function fetch_files($path = '/')
// https://developer.microsoft.com/zh-cn/graph/graph-explorer
$pos = splitlast($path, '/');
$parentpath = $pos[0];
+ if ($parentpath=='') $parentpath = '/';
$filename = $pos[1];
if ($parentfiles = getcache('path_' . $parentpath)) {
if (isset($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl'])) {
@@ -1021,6 +1029,7 @@ function fetch_files_children($files, $path, $page)
{
$path1 = path_format($path);
$path = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
$cachefilename = '.SCFcache_'.$_SERVER['function_name'];
$maxpage = ceil($files['folder']['childCount']/200);
if (!($files['children'] = getcache('files_' . $path . '_page_' . $page))) {
From a07a9cb25b8f7a9f8f4e1cb1742ab1903b808830 Mon Sep 17 00:00:00 2001
From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com>
Date: Sun, 22 Mar 2020 19:35:19 +0800
Subject: [PATCH 2/2] fix: url after upload bug in multidisk mode
---
theme/classic.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/theme/classic.php b/theme/classic.php
index 1f84ab6..aec052f 100644
--- a/theme/classic.php
+++ b/theme/classic.php
@@ -1009,7 +1009,7 @@
} else {
MiddleStr += ':'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s
';
}
- document.getElementById('upfile_td1_'+tdnum).innerHTML='