From 0d98ec7cde73670633ee564390e019140506fe66 Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Wed, 18 Dec 2024 16:15:03 +0300 Subject: [PATCH] copy folder fix --- kernel/controllers/ModuleController.php | 4 ---- kernel/helpers/Files.php | 10 ++++++++-- kernel/manifest.json | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/controllers/ModuleController.php b/kernel/controllers/ModuleController.php index e0fc983..8ce4d4e 100644 --- a/kernel/controllers/ModuleController.php +++ b/kernel/controllers/ModuleController.php @@ -6,13 +6,9 @@ use DirectoryIterator; use JetBrains\PhpStorm\NoReturn; use Josantonius\Session\Facades\Session; use kernel\AdminController; -use kernel\EntityRelation; use kernel\helpers\Debug; use kernel\models\Option; -use kernel\modules\module_shop_client\services\ModuleShopClientService; -use kernel\modules\user\service\UserService; use kernel\Request; -use kernel\services\MigrationService; use kernel\services\ModuleService; class ModuleController extends AdminController diff --git a/kernel/helpers/Files.php b/kernel/helpers/Files.php index 5f6daf7..ef154e7 100644 --- a/kernel/helpers/Files.php +++ b/kernel/helpers/Files.php @@ -7,11 +7,13 @@ use ZipArchive; 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 (!file_exists($d2)){ + $old_mask = umask(0); $_d2 = mkdir($d2, permissions: $permissions, recursive: $recursive); + umask($old_mask); if (!$_d2) { return; } @@ -26,14 +28,17 @@ class Files $d->close(); } else { 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 (!file_exists($d2)){ + $old_mask = umask(0); $_d2 = mkdir($d2, permissions: $permissions, recursive: $recursive); + umask($old_mask); if (!$_d2) { return; } @@ -48,6 +53,7 @@ class Files $d->close(); } else { copy($d1, $d2); + chmod($d2, permissions: $permissions); } } diff --git a/kernel/manifest.json b/kernel/manifest.json index 3cccfd0..65282d4 100644 --- a/kernel/manifest.json +++ b/kernel/manifest.json @@ -1,6 +1,6 @@ { "name": "Kernel", - "version": "0.1", + "version": "0.2", "author": "ITGuild", "slug": "kernel", "type": "kernel",