diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2016-08-16 15:55:08 +0300 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2016-08-26 10:38:01 +0300 |
commit | 61c9a065c2ba2473f4b2cc4f5060e7720d64d529 (patch) | |
tree | 2877952e459c84c5c5e1428f9c409df46ca4a676 /apps | |
parent | c061f130b7c051e005e764c8627c7368277fe476 (diff) |
stat for root of a share does not work
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/lib/smb.php | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index d9b85375b1b..124abc3b700 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -180,11 +180,58 @@ class SMB extends Common { */ public function stat($path) { $this->log('enter: '.__FUNCTION__."($path)"); - $result = $this->formatInfo($this->getFileInfo($path)); + if ($this->remoteIsShare() && $this->isRootDir($path)) { //mtime doesn't work for shares + $result = [ + 'mtime' => $this->shareMTime(), + 'size' => 0, + 'type' => 'dir' + ]; + } else { + $result = $this->formatInfo($this->getFileInfo($path)); + } return $this->leave(__FUNCTION__, $result); } /** + * get the best guess for the modification time of the share + * + * @return array the first element of the array is the calculated mtime for the folder, and + * the second is the list of readable files (the list contains the filename as key and the + * mtime for the file as value) + */ + private function shareMTime() { + $this->log('enter: '.__FUNCTION__, Util::DEBUG); + $files = $this->share->dir($this->root); + $result = 0; + foreach ($files as $fileInfo) { + if ($fileInfo->getMTime() > $result) { + $result = $fileInfo->getMTime(); + } + } + return $this->leave(__FUNCTION__, $result); + } + /** + * Check if the path is our root dir (not the smb one) + * + * @param string $path the path + * @return bool true if it's root, false if not + */ + private function isRootDir($path) { + $this->log('enter: '.__FUNCTION__."($path)", Util::DEBUG); + $result = $path === '' || $path === '/' || $path === '.'; + return $this->leave(__FUNCTION__, $result); + } + /** + * Check if our root points to a smb share + * + * @return bool true if our root points to a share false otherwise + */ + private function remoteIsShare() { + $this->log('enter: '.__FUNCTION__, Util::DEBUG); + $result = $this->share->getName() && (!$this->root || $this->root === '/'); + return $this->leave(__FUNCTION__, $result); + } + /** * @param string $path * @return bool * @throws StorageNotAvailableException |