*/
private $server;
+ /**
+ * State of the lock
+ *
+ * @var bool
+ */
+ private $isLocked;
+
/**
* {@inheritdoc}
*/
$this->server = $server;
$this->server->on('beforeMethod:*', [$this, 'getLock'], 50);
$this->server->on('afterMethod:*', [$this, 'releaseLock'], 50);
+ $this->isLocked = false;
}
public function getLock(RequestInterface $request) {
} catch (LockedException $e) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
+ $this->isLocked = true;
}
}
public function releaseLock(RequestInterface $request) {
+ // don't try to release the lock if we never locked one
+ if ($this->isLocked === false) {
+ return;
+ }
if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) {
return;
}
}
if ($node instanceof Node) {
$node->releaseLock(ILockingProvider::LOCK_SHARED);
+ $this->isLocked = false;
}
}
}