Merge pull request #8285 from nextcloud/apps_files-smb-catch-exceptions-on-listing

Make SMB module more fault-tolerant
This commit is contained in:
Roeland Jago Douma 2018-02-27 13:10:54 +01:00 committed by GitHub
commit 017e1325f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -152,7 +152,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);
@ -226,9 +232,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;
}