aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-08-20 14:48:48 +0200
committerGitHub <noreply@github.com>2018-08-20 14:48:48 +0200
commit1c13e7863334784292cbff902d2a8f92f05693ed (patch)
treef426ff14397328717e4e9662fed04b7c89db4a36 /apps
parent9cf11bd73cd8e35c700149779d9f0d923225acd8 (diff)
parentbdc6d0b5a1d95acc8cbce8c454bd9cfd79f0d205 (diff)
downloadnextcloud-server-1c13e7863334784292cbff902d2a8f92f05693ed.tar.gz
nextcloud-server-1c13e7863334784292cbff902d2a8f92f05693ed.zip
Merge pull request #10697 from nextcloud/smb-log-removed-entries
log entries that are hidden during file listing
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php36
1 files changed, 25 insertions, 11 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index 9c0e6910309..6ed048455cc 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -78,6 +78,9 @@ class SMB extends Common implements INotifyStorage {
*/
protected $statCache;
+ /** @var ILogger */
+ protected $logger;
+
public function __construct($params) {
if (!isset($params['host'])) {
throw new \Exception('Invalid configuration, no host provided');
@@ -92,6 +95,12 @@ class SMB extends Common implements INotifyStorage {
throw new \Exception('Invalid configuration, no credentials provided');
}
+ if (isset($params['logger'])) {
+ $this->logger = $params['logger'];
+ } else {
+ $this->logger = \OC::$server->getLogger();
+ }
+
$serverFactory = new ServerFactory();
$this->server = $serverFactory->createServer($params['host'], $auth);
$this->share = $this->server->getShare(trim($params['share'], '/'));
@@ -155,7 +164,7 @@ class SMB extends Common implements INotifyStorage {
}
return $this->statCache[$path];
} catch (ConnectException $e) {
- \OC::$server->getLogger()->logException($e, ['message' => 'Error while getting file info']);
+ $this->logger->logException($e, ['message' => 'Error while getting file info']);
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
}
}
@@ -174,15 +183,20 @@ class SMB extends Common implements INotifyStorage {
}
return array_filter($files, function (IFileInfo $file) {
try {
+ if ($file->isHidden()) {
+ $this->logger->debug('hiding hidden file ' . $file->getName());
+ }
return !$file->isHidden();
} catch (ForbiddenException $e) {
+ $this->logger->logException($e, ['level' => ILogger::DEBUG, 'message' => 'Hiding forbidden entry ' . $file->getName()]);
return false;
} catch (NotFoundException $e) {
+ $this->logger->logException($e, ['level' => ILogger::DEBUG, 'message' => 'Hiding not found entry ' . $file->getName()]);
return false;
}
});
} catch (ConnectException $e) {
- \OC::$server->getLogger()->logException($e, ['message' => 'Error while getting folder content']);
+ $this->logger->logException($e, ['message' => 'Error while getting folder content']);
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
}
}
@@ -225,7 +239,7 @@ class SMB extends Common implements INotifyStorage {
$this->remove($target);
$result = $this->share->rename($absoluteSource, $absoluteTarget, false);
} else {
- \OC::$server->getLogger()->logException($e, ['level' => ILogger::WARN]);
+ $this->logger->logException($e, ['level' => ILogger::WARN]);
return false;
}
} catch (InvalidArgumentException $e) {
@@ -233,11 +247,11 @@ class SMB extends Common implements INotifyStorage {
$this->remove($target);
$result = $this->share->rename($absoluteSource, $absoluteTarget, false);
} else {
- \OC::$server->getLogger()->logException($e, ['level' => ILogger::WARN]);
+ $this->logger->logException($e, ['level' => ILogger::WARN]);
return false;
}
} catch (\Exception $e) {
- \OC::$server->getLogger()->logException($e, ['level' => ILogger::WARN]);
+ $this->logger->logException($e, ['level' => ILogger::WARN]);
return false;
}
unset($this->statCache[$absoluteSource], $this->statCache[$absoluteTarget]);
@@ -320,7 +334,7 @@ class SMB extends Common implements INotifyStorage {
} catch (ForbiddenException $e) {
return false;
} catch (ConnectException $e) {
- \OC::$server->getLogger()->logException($e, ['message' => 'Error while deleting file']);
+ $this->logger->logException($e, ['message' => 'Error while deleting file']);
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
}
}
@@ -405,7 +419,7 @@ class SMB extends Common implements INotifyStorage {
} catch (ForbiddenException $e) {
return false;
} catch (ConnectException $e) {
- \OC::$server->getLogger()->logException($e, ['message' => 'Error while opening file']);
+ $this->logger->logException($e, ['message' => 'Error while opening file']);
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
}
}
@@ -432,7 +446,7 @@ class SMB extends Common implements INotifyStorage {
} catch (ForbiddenException $e) {
return false;
} catch (ConnectException $e) {
- \OC::$server->getLogger()->logException($e, ['message' => 'Error while removing folder']);
+ $this->logger->logException($e, ['message' => 'Error while removing folder']);
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
}
}
@@ -446,7 +460,7 @@ class SMB extends Common implements INotifyStorage {
}
return false;
} catch (ConnectException $e) {
- \OC::$server->getLogger()->logException($e, ['message' => 'Error while creating file']);
+ $this->logger->logException($e, ['message' => 'Error while creating file']);
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
}
}
@@ -482,7 +496,7 @@ class SMB extends Common implements INotifyStorage {
$this->share->mkdir($path);
return true;
} catch (ConnectException $e) {
- \OC::$server->getLogger()->logException($e, ['message' => 'Error while creating folder']);
+ $this->logger->logException($e, ['message' => 'Error while creating folder']);
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
} catch (Exception $e) {
return false;
@@ -556,7 +570,7 @@ class SMB extends Common implements INotifyStorage {
try {
return parent::test();
} catch (Exception $e) {
- \OC::$server->getLogger()->logException($e);
+ $this->logger->logException($e);
return false;
}
}