mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fixed: [wopi] add a "graceful period" when removing a lock
This ensure that requests like putFile, which comes in the same time frame, encounter a "document is unlocked" error.
This commit is contained in:
parent
583d7b24ba
commit
4fec18f3aa
@ -21,7 +21,10 @@ class ChillDocumentLockManager implements DocumentLockManagerInterface
|
||||
{
|
||||
private const LOCK_DURATION = 60 * 30;
|
||||
|
||||
private int $postDeleteLockDurationMs;
|
||||
/**
|
||||
* Number of seconds to keep the lock after the delete lock operation
|
||||
*/
|
||||
private const LOCK_GRACEFUL_DURATION_TIME = 3;
|
||||
|
||||
private ChillRedis $redis;
|
||||
|
||||
@ -32,9 +35,13 @@ class ChillDocumentLockManager implements DocumentLockManagerInterface
|
||||
|
||||
public function deleteLock(Document $document, RequestInterface $request): bool
|
||||
{
|
||||
$this->redis->del($this->getCacheId($document));
|
||||
if (0 === $this->redis->exists($this->getCacheId($document))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
// some queries (ex.: putFile) may be executed on the same time than the unlock, so
|
||||
// we add a delay before unlocking the file, instead of deleting it immediatly
|
||||
return $this->redis->expire($this->getCacheId($document), self::LOCK_GRACEFUL_DURATION_TIME);
|
||||
}
|
||||
|
||||
public function getLock(Document $document, RequestInterface $request): string
|
||||
|
@ -87,7 +87,9 @@ final class ChillDocumentManager implements DocumentManagerInterface
|
||||
|
||||
public function deleteLock(Document $document): void
|
||||
{
|
||||
$this->documentLockManager->deleteLock($document, $this->request);
|
||||
if (false ===$this->documentLockManager->deleteLock($document, $this->request)) {
|
||||
throw new \RuntimeException("could not remove the lock");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user