Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php')
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php b/apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php
index 6ad565555bf..20ada5cf320 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php
@@ -9,6 +9,8 @@
namespace Icewind\SMB;
+use Icewind\SMB\Exception\Exception;
+
class NotifyHandler implements INotifyHandler {
/**
* @var Connection
@@ -22,6 +24,12 @@ class NotifyHandler implements INotifyHandler {
private $listening = true;
+ // todo replace with static once <5.6 support is dropped
+ // see error.h
+ private static $exceptionMap = [
+ ErrorCodes::RevisionMismatch => '\Icewind\SMB\Exception\RevisionMismatchException',
+ ];
+
/**
* @param Connection $connection
* @param string $path
@@ -43,6 +51,7 @@ class NotifyHandler implements INotifyHandler {
stream_set_blocking($this->connection->getOutputStream(), 0);
$lines = [];
while (($line = $this->connection->readLine())) {
+ $this->checkForError($line);
$lines[] = $line;
}
stream_set_blocking($this->connection->getOutputStream(), 1);
@@ -59,6 +68,7 @@ class NotifyHandler implements INotifyHandler {
public function listen($callback) {
if ($this->listening) {
$this->connection->read(function ($line) use ($callback) {
+ $this->checkForError($line);
$change = $this->parseChangeLine($line);
if ($change) {
return $callback($change);
@@ -80,6 +90,13 @@ class NotifyHandler implements INotifyHandler {
}
}
+ private function checkForError($line) {
+ if (substr($line, 0, 16) === 'notify returned ') {
+ $error = substr($line, 16);
+ throw Exception::fromMap(self::$exceptionMap, $error, 'Notify is not supported with the used smb version');
+ }
+ }
+
public function stop() {
$this->listening = false;
$this->connection->close();