Merge pull request #9608 from nextcloud/smb-exceptions-on-listing
[13] Handle exception while itterating trough smb file listing
This commit is contained in:
commit
9f793f91c9
|
@ -156,7 +156,13 @@ class SMB extends Common implements INotifyStorage {
|
||||||
$this->statCache[$path . '/' . $file->getName()] = $file;
|
$this->statCache[$path . '/' . $file->getName()] = $file;
|
||||||
}
|
}
|
||||||
return array_filter($files, function (IFileInfo $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) {
|
} catch (ConnectException $e) {
|
||||||
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
|
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
|
||||||
|
@ -230,8 +236,12 @@ class SMB extends Common implements INotifyStorage {
|
||||||
$highestMTime = 0;
|
$highestMTime = 0;
|
||||||
$files = $this->share->dir($this->root);
|
$files = $this->share->dir($this->root);
|
||||||
foreach ($files as $fileInfo) {
|
foreach ($files as $fileInfo) {
|
||||||
if ($fileInfo->getMTime() > $highestMTime) {
|
try {
|
||||||
$highestMTime = $fileInfo->getMTime();
|
if ($fileInfo->getMTime() > $highestMTime) {
|
||||||
|
$highestMTime = $fileInfo->getMTime();
|
||||||
|
}
|
||||||
|
} catch (NotFoundException $e) {
|
||||||
|
// Ignore this, can happen on unavailable DFS shares
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $highestMTime;
|
return $highestMTime;
|
||||||
|
|
Loading…
Reference in New Issue