Created
September 17, 2014 19:29
-
-
Save WyriHaximus/b4d9b5d417c160bb4e24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function chownRecursive($uid = -1, $gid = -1) { | |
$deferred = new Deferred(); | |
$this->ls()->then(function($list) use ($deferred, $uid, $gid) { | |
$this->filesystem->getLoop()->futureTick(function() use ($list, $deferred, $uid, $gid) { | |
$promises = []; | |
foreach ($list as $node) { | |
if ($node instanceof Directory) { | |
$promises[] = $node->chownRecursive($uid, $gid); | |
} else { | |
$promises[] = $node->chown($uid, $gid); | |
} | |
} | |
\React\Promise\all($promises)->then(function() use ($deferred, $uid, $gid) { | |
$this->chown($uid, $gid)->then(function() use ($deferred) { | |
$deferred->resolve(); | |
}); | |
}); | |
}); | |
}); | |
return $deferred->promise(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment