diff options
author | Roland Tapken <roland@bitarbeiter.net> | 2018-02-09 17:40:00 +0100 |
---|---|---|
committer | Roland Tapken <roland@bitarbeiter.net> | 2018-02-09 17:40:00 +0100 |
commit | 8e251e5d5a3dcb220387208768a8e124dbafe0a1 (patch) | |
tree | 37360acd6b34f249adba34b5976a40ed441048e5 /apps/files_external/lib/Lib/Storage/SMB.php | |
parent | ee77f37df2f601246001abfb259479ef583314a1 (diff) | |
download | nextcloud-server-8e251e5d5a3dcb220387208768a8e124dbafe0a1.tar.gz nextcloud-server-8e251e5d5a3dcb220387208768a8e124dbafe0a1.zip |
Make SMB module more fault-tolerant
Ignore unavailable files when fetching the share's mtime
or reading directory listings. This can happen on servers using a
distributed file system (DFS) with unavailable destinations, for example
when the remote server is offline.
Signed-off-by: Roland Tapken <roland@bitarbeiter.net>
Diffstat (limited to 'apps/files_external/lib/Lib/Storage/SMB.php')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/SMB.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 58a6f65990f..f8fd37a4d48 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -152,7 +152,13 @@ class SMB extends Common implements INotifyStorage { $this->statCache[$path . '/' . $file->getName()] = $file; } return array_filter($files, function (IFileInfo $file) { - return !$file->isHidden(); + try { + return !$file->isHidden(); + } catch (ForbiddenException $e) { + return false; + } catch (NotFoundException $e) { + return false; + } }); } catch (ConnectException $e) { throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e); @@ -226,8 +232,12 @@ class SMB extends Common implements INotifyStorage { $highestMTime = 0; $files = $this->share->dir($this->root); foreach ($files as $fileInfo) { - if ($fileInfo->getMTime() > $highestMTime) { - $highestMTime = $fileInfo->getMTime(); + try { + if ($fileInfo->getMTime() > $highestMTime) { + $highestMTime = $fileInfo->getMTime(); + } + } catch (NotFoundException $e) { + // Ignore this, can happen on unavailable DFS shares } } return $highestMTime; |