allow availability recheck for external storages
This commit is contained in:
parent
750fc9ae26
commit
f603c57751
|
@ -23,6 +23,7 @@
|
|||
|
||||
namespace OCA\Files_External\Config;
|
||||
|
||||
use OC\Files\Storage\Wrapper\Availability;
|
||||
use OCA\Files_external\Migration\StorageMigrator;
|
||||
use OCP\Files\Storage;
|
||||
use OC\Files\Mount\MountPoint;
|
||||
|
@ -132,7 +133,7 @@ class ConfigAdapter implements IMountProvider {
|
|||
|
||||
try {
|
||||
$availability = $impl->getAvailability();
|
||||
if (!$availability['available']) {
|
||||
if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
|
||||
$impl = new FailedStorage(['exception' => null]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
@ -29,6 +29,16 @@ namespace OC\Files\Storage\Wrapper;
|
|||
class Availability extends Wrapper {
|
||||
const RECHECK_TTL_SEC = 600; // 10 minutes
|
||||
|
||||
public static function shouldRecheck($availability) {
|
||||
if (!$availability['available']) {
|
||||
// trigger a recheck if TTL reached
|
||||
if ((time() - $availability['last_checked']) > self::RECHECK_TTL_SEC) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -47,12 +57,9 @@ class Availability extends Wrapper {
|
|||
*/
|
||||
private function isAvailable() {
|
||||
$availability = $this->getAvailability();
|
||||
if (!$availability['available']) {
|
||||
// trigger a recheck if TTL reached
|
||||
if ((time() - $availability['last_checked']) > self::RECHECK_TTL_SEC) {
|
||||
if (self::shouldRecheck($availability)) {
|
||||
return $this->updateAvailability();
|
||||
}
|
||||
}
|
||||
return $availability['available'];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue