Skip to content

Commit

Permalink
fix: potential fix for #2
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Horton <phorton@sonatype.com>
  • Loading branch information
madpah committed Feb 17, 2022
1 parent 38c60f5 commit 46f705d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ossindex/ossindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ def _upsert_cache_with_oss_index_responses(self, oss_components: List[OssIndexCo
oc: OssIndexComponent
with self._get_cache_db() as cache_db:
for oc in oss_components:
cache_query_result: List[Document] = cache_db.search(Query().coordinates == oc.coordinates)
query: Query = Query()
cache_query_result: List[Document] = cache_db.search(query.coordinates == oc.coordinates)
if len(cache_query_result) == 0:
# New component for caching
logger.debug(' Caching new Component results for {}'.format(oc.coordinates))
Expand All @@ -187,7 +188,7 @@ def _upsert_cache_with_oss_index_responses(self, oss_components: List[OssIndexCo
cache_db.update({
'response': json.dumps(oc, cls=OssIndexJsonEncoder),
'expiry': cache_expiry.isoformat()
}, cache_query_result.pop().doc_id)
}, query.coordinates == oc.coordinates)
else:
logger.debug(' Cache is still valid for {} - not updating'.format(oc.coordinates))

Expand Down

0 comments on commit 46f705d

Please sign in to comment.