fix: list items lock race (#7133)

Co-authored-by: Tom <144813356+ttalty@users.noreply.github.com>
This commit is contained in:
Lemon 2023-12-16 02:13:29 +08:00 committed by GitHub
parent 4d5c955018
commit 6199e58532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -126,16 +126,17 @@ export class ListCommand {
ciphers = this.searchService.searchCiphersBasic(ciphers, options.search, options.trash);
}
ciphers.forEach((c, index) => {
for (let i = 0; i < ciphers.length; i++) {
const c = ciphers[i];
// Set upload immediately on the last item in the ciphers collection to avoid the event collection
// service from uploading each time.
this.eventCollectionService.collect(
await this.eventCollectionService.collect(
EventType.Cipher_ClientViewed,
c.id,
index === ciphers.length - 1,
i === ciphers.length - 1,
c.organizationId,
);
});
}
const res = new ListResponse(ciphers.map((o) => new CipherResponse(o)));
return Response.success(res);