支持从Mac本地打包的模块进行离线安装

pull/76/head
liuzhen 2018-10-09 23:34:23 +08:00
parent 6bc96814b9
commit 1e524925ef
1 changed files with 17 additions and 0 deletions

View File

@ -184,6 +184,18 @@ class Addon extends Backend
try {
Service::unzip($tmpName);
@unlink($tmpFile);
// 兼容Mac本地打包的插件
$isMacOsx = 0;
$fileInfo = $info->getInfo();
$macOsxDir = $tmpAddonDir . '__MACOSX';
$macOsxFileDir = $tmpAddonDir . substr($fileInfo['name'], 0, -4);
if (is_dir($macOsxDir) && is_dir($macOsxFileDir)) {
$tmpAddonDirBak = $tmpAddonDir;
$isMacOsx = 1;
$tmpAddonDir = $macOsxFileDir . DS;
}
$infoFile = $tmpAddonDir . 'info.ini';
if (!is_file($infoFile)) {
throw new Exception(__('Addon info file was not found'));
@ -202,6 +214,11 @@ class Addon extends Backend
//重命名插件文件夹
rename($tmpAddonDir, $newAddonDir);
// 如果是Mac需要删除多于文件夹
if ($isMacOsx) {
@rmdirs($tmpAddonDirBak);
}
try {
//默认禁用该插件
$info = get_addon_info($name);