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>
This commit is contained in:
Roland Tapken 2018-02-09 17:40:00 +01:00 committed by Robin Appelman
parent d8e3c3cb22
commit e8868c2148
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
1 changed files with 13 additions and 3 deletions

View File

@ -156,7 +156,13 @@ class SMB extends Common implements INotifyStorage {
$this->statCache[$path . '/' . $file->getName()] = $file;
}
return array_filter($files, function (IFileInfo $file) {
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);
@ -230,9 +236,13 @@ class SMB extends Common implements INotifyStorage {
$highestMTime = 0;
$files = $this->share->dir($this->root);
foreach ($files as $fileInfo) {
try {
if ($fileInfo->getMTime() > $highestMTime) {
$highestMTime = $fileInfo->getMTime();
}
} catch (NotFoundException $e) {
// Ignore this, can happen on unavailable DFS shares
}
}
return $highestMTime;
}