rollback dotclear Un|Zip class

This commit is contained in:
Jean-Christian Paul Denis 2023-04-27 21:51:51 +02:00
parent ab7e9f82c3
commit c809e2c6e0
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
4 changed files with 9 additions and 67 deletions

View File

@ -161,11 +161,6 @@ class Config extends dcNsProcess
(new Label(__('Fix newline style from files content'), Label::OUTSIDE_LABEL_AFTER))->for('pack_fixnewline')->class('classic'), (new Label(__('Fix newline style from files content'), Label::OUTSIDE_LABEL_AFTER))->for('pack_fixnewline')->class('classic'),
]), ]),
]), ]),
(new Fieldset())->class('fieldset')->legend((new Legend(__('Capability'))))->fields([
(new Text('p', $img_on . sprintf(__('Use "%s" class to zip modules.'), Utils::getZipCapability()))),
(new Text('p', $img_on . sprintf(__('Use "%s" class to unzip modules.'), Utils::getUnzipCapability()))),
(new Text('p', $check_conf)),
]),
])->render(); ])->render();
} }
} }

View File

@ -102,10 +102,10 @@ class Core
$unlink = false; $unlink = false;
if ($zip->hasFile($init)) { if ($zip->hasFile($init)) {
$unlink = true; $unlink = true;
$zip->unzip($init, $path); $zip->unzip($init, $target . DIRECTORY_SEPARATOR . $init);
} }
$zip->unzip($define, $path); $zip->unzip($define, $target . DIRECTORY_SEPARATOR . $define);
$sandbox->resetModulesList(); $sandbox->resetModulesList();
$sandbox->requireDefine($path, basename($path)); $sandbox->requireDefine($path, basename($path));
@ -125,6 +125,7 @@ class Core
} }
} }
} catch (Exception $e) { } catch (Exception $e) {
throw $e;
} }
Files::deltree($path); Files::deltree($path);
} }
@ -173,7 +174,9 @@ class Core
if ($fixnewline) { if ($fixnewline) {
Zip::$fix_newline = true; Zip::$fix_newline = true;
} }
$zip = new Zip($path);
$fp = fopen($path, 'wb');
$zip = new Zip($fp);
foreach ($exclude as $e) { foreach ($exclude as $e) {
$zip->addExclusion($e); $zip->addExclusion($e);
@ -184,6 +187,7 @@ class Core
true true
); );
$zip->write();
$zip->close(); $zip->close();
unset($zip); unset($zip);
} }

View File

@ -81,64 +81,6 @@ class Utils
return !(empty($path) || empty($file) || !is_writable(dirname($path . DIRECTORY_SEPARATOR . $file))); return !(empty($path) || empty($file) || !is_writable(dirname($path . DIRECTORY_SEPARATOR . $file)));
} }
public static function getUnzipCapability(): string
{
switch (Unzip::USE_DEFAULT) {
case Unzip::USE_PHARDATA:
if (class_exists('PharData')) {
return 'PharData';
}
if (class_exists('ZipArchive')) {
return 'ZipArchive';
}
break;
case Unzip::USE_ZIPARCHIVE:
if (class_exists('ZipArchive')) {
return 'ZipArchive';
}
if (class_exists('PharData')) {
return 'PharData';
}
break;
case Unzip::USE_LEGACY:
break;
}
return 'Legacy';
}
public static function getZipCapability(): string
{
switch (Zip::USE_DEFAULT) {
case Zip::USE_PHARDATA:
if (class_exists('PharData')) {
return 'PharData';
}
if (class_exists('ZipArchive')) {
return 'ZipArchive';
}
break;
case Zip::USE_ZIPARCHIVE:
if (class_exists('ZipArchive')) {
return 'ZipArchive';
}
if (class_exists('PharData')) {
return 'PharData';
}
break;
case Unzip::USE_LEGACY:
break;
}
return 'Legacy';
}
public static function getRepositoryDir(?string $dir): string public static function getRepositoryDir(?string $dir): string
{ {
if (empty($dir)) { if (empty($dir)) {

View File

@ -27,11 +27,12 @@ class Zip extends \Dotclear\Helper\File\Zip\Zip
* *
* @param string $name The name * @param string $name The name
* @param string $file The file * @param string $file The file
* @param string $size The size
* @param int|null $mtime The mtime * @param int|null $mtime The mtime
* *
* @return void * @return void
*/ */
protected function writeFile(string $name, string $file, ?int $mtime) protected function writeFile($name, $file, $size, $mtime)
{ {
if (!isset($this->entries[$name])) { if (!isset($this->entries[$name])) {
return; return;