Skip to content

Commit

Permalink
possible fix for cve-search/cve-search#1103
Browse files Browse the repository at this point in the history
  • Loading branch information
P-T-I committed Jun 26, 2024
1 parent fec39f7 commit 24f11ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions CveXplore/core/database_actions/db_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DatabaseAction(object):

actions = collections.namedtuple("Actions", "InsertOne UpdateOne")(0, 1)

def __init__(self, action: actions, doc: dict):
def __init__(self, action: actions, doc: dict, upsert: bool = True):
"""
Create a DatabaseAction object.
Expand All @@ -23,6 +23,7 @@ def __init__(self, action: actions, doc: dict):
"""
self.action = action
self.doc = doc
self.upsert = upsert

@property
def entry(self):
Expand All @@ -37,4 +38,6 @@ def entry(self):
if self.action == self.actions.InsertOne:
return InsertOne(self.doc)
elif self.action == self.actions.UpdateOne:
return UpdateOne({"id": self.doc["id"]}, {"$set": self.doc}, upsert=True)
return UpdateOne(
{"id": self.doc["id"]}, {"$set": self.doc}, upsert=self.upsert
)
3 changes: 1 addition & 2 deletions CveXplore/core/database_maintenance/sources_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,7 @@ def process_item(self, item):
if epss is not None:
self.queue.put(
DatabaseAction(
action=DatabaseAction.actions.UpdateOne,
doc=epss,
action=DatabaseAction.actions.UpdateOne, doc=epss, upsert=False
)
)

Expand Down

0 comments on commit 24f11ca

Please sign in to comment.