Skip to content

Commit

Permalink
FileServer: added support for permissions [Closes #168]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 19, 2024
1 parent 6ad4c51 commit 5c024b3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Deployment/FileServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
class FileServer implements Server
{
public ?int $filePermissions = null;
public ?int $dirPermissions = null;
private string $root;


Expand Down Expand Up @@ -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);
}
}


Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 5c024b3

Please sign in to comment.