Merge pull request #10589 from nextcloud/smb-stat-retry

retry smb stat on timeout
This commit is contained in:
Morris Jobke 2018-08-24 07:00:40 +02:00 committed by GitHub
commit 8563ab94aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -41,6 +41,7 @@ use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\ForbiddenException; use Icewind\SMB\Exception\ForbiddenException;
use Icewind\SMB\Exception\InvalidArgumentException; use Icewind\SMB\Exception\InvalidArgumentException;
use Icewind\SMB\Exception\NotFoundException; use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\Exception\TimedOutException;
use Icewind\SMB\IFileInfo; use Icewind\SMB\IFileInfo;
use Icewind\SMB\Native\NativeServer; use Icewind\SMB\Native\NativeServer;
use Icewind\SMB\ServerFactory; use Icewind\SMB\ServerFactory;
@ -258,13 +259,19 @@ class SMB extends Common implements INotifyStorage {
return $result; return $result;
} }
public function stat($path) { public function stat($path, $retry = true) {
try { try {
$result = $this->formatInfo($this->getFileInfo($path)); $result = $this->formatInfo($this->getFileInfo($path));
} catch (ForbiddenException $e) { } catch (ForbiddenException $e) {
return false; return false;
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
return false; return false;
} catch (TimedOutException $e) {
if ($retry) {
return $this->stat($path, false);
} else {
throw $e;
}
} }
if ($this->remoteIsShare() && $this->isRootDir($path)) { if ($this->remoteIsShare() && $this->isRootDir($path)) {
$result['mtime'] = $this->shareMTime(); $result['mtime'] = $this->shareMTime();