From 5c024b3194cd61d6d9fe90470eccf05e85b0377e Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 19 Mar 2024 23:05:23 +0100 Subject: [PATCH] FileServer: added support for permissions [Closes #168] --- src/Deployment/FileServer.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Deployment/FileServer.php b/src/Deployment/FileServer.php index f682848..d3abe30 100644 --- a/src/Deployment/FileServer.php +++ b/src/Deployment/FileServer.php @@ -16,6 +16,8 @@ */ class FileServer implements Server { + public ?int $filePermissions = null; + public ?int $dirPermissions = null; private string $root; @@ -59,6 +61,9 @@ public function readFile(string $remote, string $local): void public function writeFile(string $local, string $remote, callable $progress = null): void { Safe::copy($local, $this->root . $remote); + if ($this->filePermissions) { + $this->chmod($remote, $this->filePermissions); + } } @@ -91,7 +96,7 @@ public function renameFile(string $old, string $new): void public function createDir(string $dir): void { if (trim($dir, '/') !== '' && !file_exists($path = $this->root . $dir)) { - Safe::mkdir($path, 0777, true); + Safe::mkdir($path, $this->dirPermissions ?? 0777, true); } }