diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php index 0ed31ba854..8d6fc4b336 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 9b394df8ca..99d6f7dbe5 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');