Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/storage.py
Show First 20 Lines • Show All 356 Lines • ▼ Show 20 Lines | def directory_add(self, directories: List[Directory]) -> Dict: | ||||
self._cql_runner.directory_add_one(DirectoryRow(id=directory.id)) | self._cql_runner.directory_add_one(DirectoryRow(id=directory.id)) | ||||
return {"directory:add": len(directories)} | return {"directory:add": len(directories)} | ||||
def directory_missing(self, directories: List[Sha1Git]) -> Iterable[Sha1Git]: | def directory_missing(self, directories: List[Sha1Git]) -> Iterable[Sha1Git]: | ||||
return self._cql_runner.directory_missing(directories) | return self._cql_runner.directory_missing(directories) | ||||
def _join_dentry_to_content(self, dentry: DirectoryEntry) -> Dict[str, Any]: | def _join_dentry_to_content(self, dentry: DirectoryEntry) -> Dict[str, Any]: | ||||
contents: Union[List[Content], List[SkippedContentRow]] | |||||
keys = ( | keys = ( | ||||
"status", | "status", | ||||
"sha1", | "sha1", | ||||
"sha1_git", | "sha1_git", | ||||
"sha256", | "sha256", | ||||
"length", | "length", | ||||
) | ) | ||||
ret = dict.fromkeys(keys) | ret = dict.fromkeys(keys) | ||||
ret.update(dentry.to_dict()) | ret.update(dentry.to_dict()) | ||||
if ret["type"] == "file": | if ret["type"] == "file": | ||||
contents = self.content_find({"sha1_git": ret["target"]}) | contents = self.content_find({"sha1_git": ret["target"]}) | ||||
if not contents: | |||||
tokens = list( | |||||
self._cql_runner.skipped_content_get_tokens_from_single_hash( | |||||
"sha1_git", ret["target"] | |||||
) | |||||
) | |||||
if tokens: | |||||
contents = list( | |||||
self._cql_runner.skipped_content_get_from_token(tokens[0]) | |||||
) | |||||
if contents: | if contents: | ||||
content = contents[0] | content = contents[0] | ||||
for key in keys: | for key in keys: | ||||
ret[key] = getattr(content, key) | ret[key] = getattr(content, key) | ||||
return ret | return ret | ||||
def _directory_ls( | def _directory_ls( | ||||
self, directory_id: Sha1Git, recursive: bool, prefix: bytes = b"" | self, directory_id: Sha1Git, recursive: bool, prefix: bytes = b"" | ||||
▲ Show 20 Lines • Show All 920 Lines • Show Last 20 Lines |