summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Lib/Storage/SMB.php
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-08-15 15:08:50 +0200
committerRobin Appelman <robin@icewind.nl>2018-08-16 01:20:05 +0200
commitbdc6d0b5a1d95acc8cbce8c454bd9cfd79f0d205 (patch)
tree069b0207971017e01e29914038f846353463d55c /apps/files_external/lib/Lib/Storage/SMB.php
parent0757c5298035eebb1b304bff1f1bc2025aa2bf91 (diff)
downloadnextcloud-server-bdc6d0b5a1d95acc8cbce8c454bd9cfd79f0d205.tar.gz
nextcloud-server-bdc6d0b5a1d95acc8cbce8c454bd9cfd79f0d205.zip
log entries that are hidden during file listing
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/lib/Lib/Storage/SMB.php')
-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;
}
}