From 0f47c27ccf104554ddae40e4c9fad11f9479aa9a Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Wed, 9 Dec 2015 21:45:28 +0100 Subject: [PATCH] Fix #6: Ignore UID / GID @ chown if -1 --- lib/BlockingDriver.php | 16 +++++++++------- lib/functions.php | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/BlockingDriver.php b/lib/BlockingDriver.php index 5542c3a..202b74a 100644 --- a/lib/BlockingDriver.php +++ b/lib/BlockingDriver.php @@ -247,17 +247,19 @@ class BlockingDriver implements Driver { * {@inheritdoc} */ public function chown($path, $uid, $gid) { - if (!@\chown($path, $uid)) { + if ($uid !== -1 && !@\chown($path, $uid)) { return new Failure(new FilesystemException( \error_get_last()["message"] )); - } elseif (!@\chgrp($path, $gid)) { - return new Failure(new FilesystemException( - \error_get_last()["message"] - )); - } else { - return new Success; } + + if ($gid !== -1 && !@\chgrp($path, $gid)) { + return new Failure(new FilesystemException( + \error_get_last()["message"] + )); + } + + return new Success; } /** diff --git a/lib/functions.php b/lib/functions.php index 2aa8d59..543454c 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -240,11 +240,11 @@ function chmod($path, $mode) { * chown a file or directory * * @param string $path - * @param int $uid - * @param int $gid + * @param int $uid -1 to ignore + * @param int $gid -1 to ignore * @return \Amp\Promise */ -function chown($path, $uid, $gid) { +function chown($path, $uid, $gid = -1) { return filesystem()->chown($path, $uid, $gid); }