mirror of
https://github.com/danog/file.git
synced 2024-11-30 04:19:39 +01:00
Merge pull request #7 from amphp/patch-chown-ignore
Fix #6: Ignore UID / GID @ chown if -1
This commit is contained in:
commit
11d8c79db4
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user