Merge pull request #9608 from nextcloud/smb-exceptions-on-listing

[13] Handle exception while itterating trough smb file listing
This commit is contained in:
Morris Jobke 2018-05-29 17:01:51 +02:00 committed by GitHub
commit 9f793f91c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {
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);
@ -230,8 +236,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;