copy folder fix

This commit is contained in:
Билай Станислав 2024-12-18 16:15:03 +03:00
parent a0a99de862
commit 0d98ec7cde
3 changed files with 9 additions and 7 deletions

View File

@ -6,13 +6,9 @@ use DirectoryIterator;
use JetBrains\PhpStorm\NoReturn; use JetBrains\PhpStorm\NoReturn;
use Josantonius\Session\Facades\Session; use Josantonius\Session\Facades\Session;
use kernel\AdminController; use kernel\AdminController;
use kernel\EntityRelation;
use kernel\helpers\Debug; use kernel\helpers\Debug;
use kernel\models\Option; use kernel\models\Option;
use kernel\modules\module_shop_client\services\ModuleShopClientService;
use kernel\modules\user\service\UserService;
use kernel\Request; use kernel\Request;
use kernel\services\MigrationService;
use kernel\services\ModuleService; use kernel\services\ModuleService;
class ModuleController extends AdminController class ModuleController extends AdminController

View File

@ -7,11 +7,13 @@ use ZipArchive;
class Files class Files
{ {
public function copy_folder($d1, $d2, int $permissions = 0774, bool $recursive = true): void public function copy_folder($d1, $d2, int $permissions = 0775, bool $recursive = true): void
{ {
if (is_dir($d1)) { if (is_dir($d1)) {
if (!file_exists($d2)){ if (!file_exists($d2)){
$old_mask = umask(0);
$_d2 = mkdir($d2, permissions: $permissions, recursive: $recursive); $_d2 = mkdir($d2, permissions: $permissions, recursive: $recursive);
umask($old_mask);
if (!$_d2) { if (!$_d2) {
return; return;
} }
@ -26,14 +28,17 @@ class Files
$d->close(); $d->close();
} else { } else {
copy($d1, $d2); copy($d1, $d2);
chmod($d2, permissions: $permissions);
} }
} }
public function copyKernelFolder($d1, $d2, int $permissions = 0774, bool $recursive = true): void public function copyKernelFolder($d1, $d2, int $permissions = 0773, bool $recursive = true): void
{ {
if (is_dir($d1)) { if (is_dir($d1)) {
if (!file_exists($d2)){ if (!file_exists($d2)){
$old_mask = umask(0);
$_d2 = mkdir($d2, permissions: $permissions, recursive: $recursive); $_d2 = mkdir($d2, permissions: $permissions, recursive: $recursive);
umask($old_mask);
if (!$_d2) { if (!$_d2) {
return; return;
} }
@ -48,6 +53,7 @@ class Files
$d->close(); $d->close();
} else { } else {
copy($d1, $d2); copy($d1, $d2);
chmod($d2, permissions: $permissions);
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "Kernel", "name": "Kernel",
"version": "0.1", "version": "0.2",
"author": "ITGuild", "author": "ITGuild",
"slug": "kernel", "slug": "kernel",
"type": "kernel", "type": "kernel",