Also support SnappyMail\TAR on core update

This commit is contained in:
the-djmaze 2023-01-31 09:31:01 +01:00
parent b1471c2bbd
commit fa3d4727f9
2 changed files with 13 additions and 10 deletions

View file

@ -263,18 +263,18 @@ abstract class Repository
}
if ($sTmp) {
if (\class_exists('PharData')) {
$oArchive = new \PharData($sTmp, 0, $sRealFile);
} else {
// throw new \Exception('PHP Phar is disabled, you must enable it');
$oArchive = new \SnappyMail\TAR($sTmp);
}
if (!static::deletePackageDir($sId)) {
throw new \Exception('Cannot remove previous plugin folder: '.$sId);
}
if ('.phar' === \substr($sRealFile, -5)) {
$bResult = \copy($sTmp, APP_PLUGINS_PATH . \basename($sRealFile));
} else {
if (\class_exists('PharData')) {
$oArchive = new \PharData($sTmp, 0, $sRealFile);
} else {
// throw new \Exception('PHP Phar is disabled, you must enable it');
$oArchive = new \SnappyMail\TAR($sTmp);
}
$bResult = $oArchive->extractTo(\rtrim(APP_PLUGINS_PATH, '\\/'));
}
if (!$bResult) {

View file

@ -197,16 +197,19 @@ abstract class Upgrade
throw new \Exception('Failed to download latest SnappyMail');
}
$target = \rtrim(APP_INDEX_ROOT_PATH, '\\/');
$oArchive = new \PharData($sTmp, 0, null, \Phar::GZ);
if (\class_exists('PharData')) {
$oArchive = new \PharData($sTmp, 0, null, \Phar::GZ);
} else {
$oArchive = new \SnappyMail\TAR($sTmp);
}
\error_log('Extract to ' . $target);
// $bResult = $oArchive->extractTo($target, null, true);
$bResult = $oArchive->extractTo($target, 'snappymail/')
&& $oArchive->extractTo($target, 'index.php', true);
if ($bResult) {
\error_log('Update success');
} else {
if (!$bResult) {
throw new \Exception('Extract core files failed');
}
\error_log('Update success');
// opcache_reset is a terrible solution
// \is_callable('opcache_reset') && \opcache_reset();
\is_callable('opcache_invalidate') && \opcache_invalidate($target.'/index.php', true);