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:
parent
ee77f37df2
commit
8e251e5d5a
|
@ -152,7 +152,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) {
|
||||||
|
try {
|
||||||
return !$file->isHidden();
|
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);
|
||||||
|
@ -226,9 +232,13 @@ 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) {
|
||||||
|
try {
|
||||||
if ($fileInfo->getMTime() > $highestMTime) {
|
if ($fileInfo->getMTime() > $highestMTime) {
|
||||||
$highestMTime = $fileInfo->getMTime();
|
$highestMTime = $fileInfo->getMTime();
|
||||||
}
|
}
|
||||||
|
} catch (NotFoundException $e) {
|
||||||
|
// Ignore this, can happen on unavailable DFS shares
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $highestMTime;
|
return $highestMTime;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue