keep the share usable with the notify command is running

This commit is contained in:
Robin Appelman 2016-04-26 14:41:03 +02:00
commit 862bf0825d

View file

@ -355,10 +355,10 @@ class Share extends AbstractShare {
* @return mixed * @return mixed
*/ */
public function notify($path, callable $callback) { public function notify($path, callable $callback) {
$this->connect(); $connection = $this->getConnection(); // use a fresh connection since the notify command blocks the process
$command = 'notify ' . $this->escapePath($path); $command = 'notify ' . $this->escapePath($path);
$this->connection->write($command . PHP_EOL); $connection->write($command . PHP_EOL);
$this->connection->read(function ($line) use ($callback, $path) { $connection->read(function ($line) use ($callback, $path) {
$code = (int)substr($line, 0, 4); $code = (int)substr($line, 0, 4);
$subPath = substr($line, 5); $subPath = substr($line, 5);
if ($path === '') { if ($path === '') {