From 29e9fea5623df635a30b54664ae435766cb01015 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 5 Aug 2021 18:13:37 +0800 Subject: [PATCH] try fix bug --- platform/Vercel.php | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/platform/Vercel.php b/platform/Vercel.php index 539fbc7..3f38087 100644 --- a/platform/Vercel.php +++ b/platform/Vercel.php @@ -86,8 +86,12 @@ function getConfig($str, $disktag = '') function setConfig($arr, $disktag = '') { if ($disktag=='') $disktag = $_SERVER['disktag']; - $disktags = explode("|",getConfig('disktag')); - if ($disktag!='') $diskconfig = json_decode(getenv($disktag), true); + $disktags = explode("|", getenv('disktag')); + if ($disktag!='') { + $tmp = getenv($disktag); + if (is_array($tmp)) $diskconfig = $tmp; + else $diskconfig = json_decode($tmp, true); + } $tmp = []; $indisk = 0; $operatedisk = 0; @@ -381,33 +385,3 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath); } - -function moveFolder($from, $to, $slash) -{ - if (substr($from, -1)==$slash) $from = substr($from, 0, -1); - if (substr($to, -1)==$slash) $to = substr($to, 0, -1); - if (!file_exists($to)) mkdir($to, 0777); - $handler=opendir($from); - while($filename=readdir($handler)) { - if($filename != '.' && $filename != '..'){ - $fromfile = $from . $slash . $filename; - $tofile = $to . $slash . $filename; - if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归 - $response = moveFolder($fromfile, $tofile, $slash); - if (api_error(setConfigResponse($response))) return $response; - }else{ - //if (file_exists($tofile)) unlink($tofile); - $response = rename($fromfile, $tofile); - if (!$response) { - $tmp['code'] = "Move Failed"; - $tmp['message'] = "Can not move " . $fromfile . " to " . $tofile; - return json_encode($tmp); - } - if (file_exists($fromfile)) unlink($fromfile); - } - } - } - closedir($handler); - rmdir($from); - return json_encode( [ 'response' => 'success' ] ); -}