Prevent concurrent availability checks
This commit is contained in:
parent
ddbebe91f0
commit
77cec29b10
|
@ -40,9 +40,13 @@ class Availability extends Wrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Only called if availability === false
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function updateAvailability() {
|
private function updateAvailability() {
|
||||||
|
// reset availability to false so that multiple requests don't recheck concurrently
|
||||||
|
$this->setAvailability(false);
|
||||||
try {
|
try {
|
||||||
$result = $this->test();
|
$result = $this->test();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
|
@ -74,9 +74,12 @@ class Availability extends \Test\TestCase {
|
||||||
$storage->expects($this->once())
|
$storage->expects($this->once())
|
||||||
->method('test')
|
->method('test')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
$storage->expects($this->once())
|
$storage->expects($this->exactly(2))
|
||||||
->method('setAvailability')
|
->method('setAvailability')
|
||||||
->with($this->equalTo(true));
|
->withConsecutive(
|
||||||
|
[$this->equalTo(false)], // prevents concurrent rechecks
|
||||||
|
[$this->equalTo(true)] // sets correct availability
|
||||||
|
);
|
||||||
$storage->expects($this->once())
|
$storage->expects($this->once())
|
||||||
->method('mkdir');
|
->method('mkdir');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue