summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-03-03 14:19:34 +0100
committerRobin Appelman <icewind@owncloud.com>2016-03-03 14:19:34 +0100
commit6990100e6ed6d1efe48e2688331df5ce364f9fd5 (patch)
treebad3332a3cc420eef51fabaf7b4ee799ab8f27d4 /lib
parent4f25f341788b3edad1bf4baf739cd632785c9abb (diff)
downloadnextcloud-server-6990100e6ed6d1efe48e2688331df5ce364f9fd5.tar.gz
nextcloud-server-6990100e6ed6d1efe48e2688331df5ce364f9fd5.zip
allow availability recheck for external storages
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/storage/wrapper/availability.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/private/files/storage/wrapper/availability.php b/lib/private/files/storage/wrapper/availability.php
index 55ddb0d5e8f..0ed31ba854a 100644
--- a/lib/private/files/storage/wrapper/availability.php
+++ b/lib/private/files/storage/wrapper/availability.php
@@ -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,11 +57,8 @@ 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) {
- return $this->updateAvailability();
- }
+ if (self::shouldRecheck($availability)) {
+ return $this->updateAvailability();
}
return $availability['available'];
}