Skip to content

Commit

Permalink
perf: Avoid re-query of already fetched lock info
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and backportbot-nextcloud[bot] committed Dec 19, 2023
1 parent 0401fb1 commit 03606e5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Service/LockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -156,6 +157,10 @@ public function getLockForNodeIds(array $nodeIds): array {
}
}

if (count($expiredLocks) > 0) {
$this->locksRequest->removeIds($expiredLocks);
}

return $locks;
}

Expand Down

0 comments on commit 03606e5

Please sign in to comment.