Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/loader.py
Show First 20 Lines • Show All 404 Lines • ▼ Show 20 Lines | def _load_revision(self, p_info, origin) -> Optional[Sha1Git]: | ||||
) | ) | ||||
contents: List[Content] = [] | contents: List[Content] = [] | ||||
skipped_contents: List[SkippedContent] = [] | skipped_contents: List[SkippedContent] = [] | ||||
directories: List[Directory] = [] | directories: List[Directory] = [] | ||||
for obj in directory.iter_tree(): | for obj in directory.iter_tree(): | ||||
obj = obj.to_model() | obj = obj.to_model() | ||||
if isinstance(obj, Content): | obj_type = obj.object_type | ||||
if obj_type in ("content", "content_file"): | |||||
# FIXME: read the data from disk later (when the | # FIXME: read the data from disk later (when the | ||||
# storage buffer is flushed). | # storage buffer is flushed). | ||||
obj = obj.with_data() | obj = obj.with_data() | ||||
contents.append(obj) | contents.append(obj) | ||||
elif isinstance(obj, SkippedContent): | elif obj_type == "skipped_content": | ||||
skipped_contents.append(obj) | skipped_contents.append(obj) | ||||
elif isinstance(obj, Directory): | elif obj_type == "directory": | ||||
directories.append(obj) | directories.append(obj) | ||||
else: | else: | ||||
raise TypeError(f"Unexpected content type from disk: {obj}") | raise TypeError(f"Unexpected content type from disk: {obj}") | ||||
logger.debug("Number of skipped contents: %s", len(skipped_contents)) | logger.debug("Number of skipped contents: %s", len(skipped_contents)) | ||||
self.storage.skipped_content_add(skipped_contents) | self.storage.skipped_content_add(skipped_contents) | ||||
logger.debug("Number of contents: %s", len(contents)) | logger.debug("Number of contents: %s", len(contents)) | ||||
self.storage.content_add(contents) | self.storage.content_add(contents) | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |