summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2016-10-10 14:44:53 +0200
committerRobin Appelman <robin@icewind.nl>2016-10-11 11:09:05 +0200
commit85bd5589cb2ed7c689a8bf5af606bfa95dca219c (patch)
tree9eafb9f9276c57aed4ce67e26f44e49a66c4fde6 /apps/files_external
parent2dcd97bf144fac80d68df813d9d002bcbe3e1d6b (diff)
downloadnextcloud-server-85bd5589cb2ed7c689a8bf5af606bfa95dca219c.tar.gz
nextcloud-server-85bd5589cb2ed7c689a8bf5af606bfa95dca219c.zip
Fix mtimes for share root
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php46
1 files changed, 44 insertions, 2 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index 28445dd2f61..e98cbefaec3 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -35,6 +35,7 @@ use Icewind\SMB\Exception\ConnectException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\ForbiddenException;
use Icewind\SMB\Exception\NotFoundException;
+use Icewind\SMB\IFileInfo;
use Icewind\SMB\IShare;
use Icewind\SMB\NativeServer;
use Icewind\SMB\Server;
@@ -146,7 +147,9 @@ class SMB extends Common implements INotifyStorage {
foreach ($files as $file) {
$this->statCache[$path . '/' . $file->getName()] = $file;
}
- return $files;
+ return array_filter($files, function(IFileInfo $file) {
+ return !$file->isHidden();
+ });
} catch (ConnectException $e) {
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
}
@@ -168,7 +171,46 @@ class SMB extends Common implements INotifyStorage {
* @return array
*/
public function stat($path) {
- return $this->formatInfo($this->getFileInfo($path));
+ $result = $this->formatInfo($this->getFileInfo($path));
+ if ($this->remoteIsShare() && $this->isRootDir($path)) {
+ $result['mtime'] = $this->shareMTime();
+ }
+ return $result;
+ }
+
+ /**
+ * get the best guess for the modification time of the share
+ *
+ * @return int
+ */
+ private function shareMTime() {
+ $highestMTime = 0;
+ $files = $this->share->dir($this->root);
+ foreach ($files as $fileInfo) {
+ if ($fileInfo->getMTime() > $highestMTime) {
+ $highestMTime = $fileInfo->getMTime();
+ }
+ }
+ return $highestMTime;
+ }
+
+ /**
+ * Check if the path is our root dir (not the smb one)
+ *
+ * @param string $path the path
+ * @return bool
+ */
+ private function isRootDir($path) {
+ return $path === '' || $path === '/' || $path === '.';
+ }
+
+ /**
+ * Check if our root points to a smb share
+ *
+ * @return bool true if our root points to a share false otherwise
+ */
+ private function remoteIsShare() {
+ return $this->share->getName() && (!$this->root || $this->root === '/');
}
/**