aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-04-29 17:43:31 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-04-29 17:43:31 +0200
commite59ccc5fe929e63c6655c01828e6231643280b29 (patch)
treef6a9717221cad44740ef6a455b0b08065b1342af
parentf79a81258e5a1ecc5563b6d7bcf0a161de7ec44f (diff)
parent77cec29b108df7d9c868d60baf74fbe9b64e08f5 (diff)
downloadnextcloud-server-e59ccc5fe929e63c6655c01828e6231643280b29.tar.gz
nextcloud-server-e59ccc5fe929e63c6655c01828e6231643280b29.zip
Merge pull request #24299 from owncloud/availability-avoid-concurrency
Prevent concurrent storage availability checks
-rw-r--r--lib/private/Files/Storage/Wrapper/Availability.php4
-rw-r--r--tests/lib/files/storage/wrapper/availability.php7
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php
index 0ed31ba854a..8d6fc4b3369 100644
--- a/lib/private/Files/Storage/Wrapper/Availability.php
+++ b/lib/private/Files/Storage/Wrapper/Availability.php
@@ -40,9 +40,13 @@ class Availability extends Wrapper {
}
/**
+ * Only called if availability === false
+ *
* @return bool
*/
private function updateAvailability() {
+ // reset availability to false so that multiple requests don't recheck concurrently
+ $this->setAvailability(false);
try {
$result = $this->test();
} catch (\Exception $e) {
diff --git a/tests/lib/files/storage/wrapper/availability.php b/tests/lib/files/storage/wrapper/availability.php
index 9b394df8ca3..99d6f7dbe5c 100644
--- a/tests/lib/files/storage/wrapper/availability.php
+++ b/tests/lib/files/storage/wrapper/availability.php
@@ -74,9 +74,12 @@ class Availability extends \Test\TestCase {
$storage->expects($this->once())
->method('test')
->willReturn(true);
- $storage->expects($this->once())
+ $storage->expects($this->exactly(2))
->method('setAvailability')
- ->with($this->equalTo(true));
+ ->withConsecutive(
+ [$this->equalTo(false)], // prevents concurrent rechecks
+ [$this->equalTo(true)] // sets correct availability
+ );
$storage->expects($this->once())
->method('mkdir');