1
0
mirror of https://github.com/danog/file.git synced 2024-11-26 11:54:54 +01:00

Merge pull request #7 from amphp/patch-chown-ignore

Fix #6: Ignore UID / GID @ chown if -1
This commit is contained in:
Bob Weinand 2015-12-09 21:59:25 +01:00
commit 11d8c79db4
2 changed files with 12 additions and 10 deletions

View File

@ -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;
}
/**

View File

@ -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<null>
*/
function chown($path, $uid, $gid) {
function chown($path, $uid, $gid = -1) {
return filesystem()->chown($path, $uid, $gid);
}