diff --git a/lib/Service/LockService.php b/lib/Service/LockService.php index 7adabe9b..6540e24a 100644 --- a/lib/Service/LockService.php +++ b/lib/Service/LockService.php @@ -132,6 +132,7 @@ public function getLockForNodeIds(array $nodeIds): array { $locks[$nodeId] = $this->lockCache[$nodeId]; } else { $locksToRequest[] = $nodeId; + $this->lockCache[$nodeId] = false; } } if (count($locksToRequest) === 0) { @@ -144,10 +145,10 @@ public function getLockForNodeIds(array $nodeIds): array { } $newLocks = array_merge(...$newLocks); + $expiredLocks = []; foreach ($newLocks as $lock) { if ($lock->getETA() === 0) { - // TODO batch remove - $this->locksRequest->delete($lock); + $expiredLocks[] = $lock->getId(); $locks[$lock->getFileId()] = false; $this->lockCache[$lock->getFileId()] = false; } else { @@ -156,6 +157,10 @@ public function getLockForNodeIds(array $nodeIds): array { } } + if (count($expiredLocks) > 0) { + $this->locksRequest->removeIds($expiredLocks); + } + return $locks; }