Skip to content
Snippets Groups Projects
Commit 452fa224 authored by vlorentz's avatar vlorentz
Browse files

loader: Stop materializing full lists of objects to be stored.

Since 43728c59, store_data consumes the entire iterator
of contents, and since 3b97703d, it does the same for
other object types.

This causes all the (new) objects of the loaded repository to be loaded
in memory at the same time before being sent to the storage, which can
cause OOM errors.

Instead, with this commit, objects are added one by one to the storage,
which restores the lazy behavior we had before these two commits using
the buffered storage proxy.
parent 64922781
No related branches found
Tags v0.11.0
1 merge request!363loader: Stop materializing full lists of objects to be stored.
......@@ -411,23 +411,22 @@ class DVCSLoader(BaseLoader):
self.save_data()
if self.has_contents():
contents = []
skipped_contents = []
for obj in self.get_contents():
if isinstance(obj, Content):
contents.append(obj)
self.storage.content_add([obj])
elif isinstance(obj, SkippedContent):
skipped_contents.append(obj)
self.storage.skipped_content_add([obj])
else:
raise TypeError(f"Unexpected content type: {obj}")
self.storage.skipped_content_add(skipped_contents)
self.storage.content_add(contents)
if self.has_directories():
self.storage.directory_add(list(self.get_directories()))
for directory in self.get_directories():
self.storage.directory_add([directory])
if self.has_revisions():
self.storage.revision_add(list(self.get_revisions()))
for revision in self.get_revisions():
self.storage.revision_add([revision])
if self.has_releases():
self.storage.release_add(list(self.get_releases()))
for release in self.get_releases():
self.storage.release_add([release])
snapshot = self.get_snapshot()
self.storage.snapshot_add([snapshot])
self.flush()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment