Skip to content

Commit

Permalink
Merge pull request #1723 from skynet2/duplicate-key-ldcontext
Browse files Browse the repository at this point in the history
fix: duplicate key ldcontext
  • Loading branch information
fqutishat committed May 20, 2024
2 parents 1f13499 + f0f6b27 commit 4e496dc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/storage/mongodb/ldstore/context_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func (s *ContextStore) Put(u string, rd *jsonld.RemoteDocument) error {
}

if _, err = collection.InsertOne(ctxWithTimeout, bsonDoc); err != nil {
if mongo.IsDuplicateKeyError(err) {
s.cache.Add(rd.ContextURL, rd)
return nil
}

return fmt.Errorf("insert document: %w", err)
}

Expand Down

0 comments on commit 4e496dc

Please sign in to comment.