|
8 | 8 | namespace Icewind\SMB;
|
9 | 9 |
|
10 | 10 | use Icewind\SMB\Exception\ConnectionException;
|
| 11 | +use Icewind\SMB\Exception\DependencyException; |
11 | 12 | use Icewind\SMB\Exception\FileInUseException;
|
12 | 13 | use Icewind\SMB\Exception\InvalidTypeException;
|
13 | 14 | use Icewind\SMB\Exception\NotFoundException;
|
@@ -53,7 +54,8 @@ public function __construct($server, $name) {
|
53 | 54 |
|
54 | 55 | protected function getConnection() {
|
55 | 56 | $workgroupArgument = ($this->server->getWorkgroup()) ? ' -W ' . escapeshellarg($this->server->getWorkgroup()) : '';
|
56 |
| - $command = sprintf('stdbuf -o0 %s %s --authentication-file=%s %s', |
| 57 | + $command = sprintf('%s%s %s --authentication-file=%s %s', |
| 58 | + $this->system->hasStdBuf() ? 'stdbuf -o0 ' : '', |
57 | 59 | $this->system->getSmbclientPath(),
|
58 | 60 | $workgroupArgument,
|
59 | 61 | System::getFD(3),
|
@@ -353,8 +355,13 @@ public function setMode($path, $mode) {
|
353 | 355 | * @param string $path
|
354 | 356 | * @param callable $callback callable which will be called for each received change
|
355 | 357 | * @return mixed
|
| 358 | + * @throws ConnectionException |
| 359 | + * @throws DependencyException |
356 | 360 | */
|
357 | 361 | public function notify($path, callable $callback) {
|
| 362 | + if (!$this->system->hasStdBuf()) { //stdbuf is required to disable smbclient's output buffering |
| 363 | + throw new DependencyException('stdbuf is required for usage of the notify command'); |
| 364 | + } |
358 | 365 | $connection = $this->getConnection(); // use a fresh connection since the notify command blocks the process
|
359 | 366 | $command = 'notify ' . $this->escapePath($path);
|
360 | 367 | $connection->write($command . PHP_EOL);
|
|
0 commit comments