mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-08 05:18:40 +00:00
fix archives
This commit is contained in:
parent
82fd468519
commit
0df18d08e1
|
|
@ -34,12 +34,14 @@ class Tar implements ArchiveInterface
|
||||||
public static function pack(string | array $sources, string $destination, bool $overwrite = false) : bool
|
public static function pack(string | array $sources, string $destination, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
|
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
|
||||||
if (!$overwrite && \is_file($destination)) {
|
if ((!$overwrite && \is_file($destination))
|
||||||
|
|| \is_dir($destination)
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\is_string($sources)) {
|
if (\is_string($sources)) {
|
||||||
$sources = [$sources];
|
$sources = [$sources => ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tar = new \PharData($destination);
|
$tar = new \PharData($destination);
|
||||||
|
|
@ -52,7 +54,7 @@ class Tar implements ArchiveInterface
|
||||||
$source = $relative;
|
$source = $relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
$source = \str_replace('\\', '/', $source);
|
$source = FileUtils::absolute(\str_replace('\\', '/', $source));
|
||||||
$relative = \str_replace('\\', '/', $relative);
|
$relative = \str_replace('\\', '/', $relative);
|
||||||
|
|
||||||
if (\is_dir($source)) {
|
if (\is_dir($source)) {
|
||||||
|
|
@ -73,7 +75,7 @@ class Tar implements ArchiveInterface
|
||||||
|
|
||||||
$absolute = \realpath($file);
|
$absolute = \realpath($file);
|
||||||
$absolute = \str_replace('\\', '/', (string) $absolute);
|
$absolute = \str_replace('\\', '/', (string) $absolute);
|
||||||
$dir = \rtrim($relative, '/\\') . '/' . \ltrim(\str_replace($source . '/', '', $absolute), '/\\');
|
$dir = \ltrim(\rtrim($relative, '/\\') . '/' . \ltrim(\str_replace($source . '/', '', $absolute), '/\\'), '/\\');
|
||||||
|
|
||||||
if (\is_dir($absolute)) {
|
if (\is_dir($absolute)) {
|
||||||
$tar->addEmptyDir($dir . '/');
|
$tar->addEmptyDir($dir . '/');
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class Zip implements ArchiveInterface
|
||||||
public static function pack(string | array $sources, string $destination, bool $overwrite = false) : bool
|
public static function pack(string | array $sources, string $destination, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
|
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
|
||||||
if (!$overwrite && \is_file($destination)
|
if ((!$overwrite && \is_file($destination))
|
||||||
|| \is_dir($destination)
|
|| \is_dir($destination)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user