Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/mongo/backend.py
Show All 19 Lines | from ..interface import ( | ||||
RevisionData, | RevisionData, | ||||
) | ) | ||||
class ProvenanceStorageMongoDb: | class ProvenanceStorageMongoDb: | ||||
def __init__(self, db: pymongo.database.Database): | def __init__(self, db: pymongo.database.Database): | ||||
self.db = db | self.db = db | ||||
def close(self) -> None: | |||||
pass | |||||
def content_add( | def content_add( | ||||
self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] | self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] | ||||
) -> bool: | ) -> bool: | ||||
data = cnts if isinstance(cnts, dict) else dict.fromkeys(cnts) | data = cnts if isinstance(cnts, dict) else dict.fromkeys(cnts) | ||||
existing = { | existing = { | ||||
x["sha1"]: x | x["sha1"]: x | ||||
for x in self.db.content.find( | for x in self.db.content.find( | ||||
{"sha1": {"$in": list(data)}}, {"sha1": 1, "ts": 1, "_id": 1} | {"sha1": {"$in": list(data)}}, {"sha1": 1, "ts": 1, "_id": 1} | ||||
▲ Show 20 Lines • Show All 425 Lines • Show Last 20 Lines |