try fix bug

pull/397/head
qkqpttgf 2021-08-05 18:13:37 +08:00 committed by GitHub
parent 80d93cb852
commit 29e9fea562
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 32 deletions

View File

@ -86,8 +86,12 @@ function getConfig($str, $disktag = '')
function setConfig($arr, $disktag = '') function setConfig($arr, $disktag = '')
{ {
if ($disktag=='') $disktag = $_SERVER['disktag']; if ($disktag=='') $disktag = $_SERVER['disktag'];
$disktags = explode("|",getConfig('disktag')); $disktags = explode("|", getenv('disktag'));
if ($disktag!='') $diskconfig = json_decode(getenv($disktag), true); if ($disktag!='') {
$tmp = getenv($disktag);
if (is_array($tmp)) $diskconfig = $tmp;
else $diskconfig = json_decode($tmp, true);
}
$tmp = []; $tmp = [];
$indisk = 0; $indisk = 0;
$operatedisk = 0; $operatedisk = 0;
@ -381,33 +385,3 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath); 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' ] );
}