Skip to content

Commit

Permalink
fixup! Fix large exports
Browse files Browse the repository at this point in the history
  • Loading branch information
quba42 committed May 22, 2024
1 parent ce0c796 commit 664ce50
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pulpcore/app/importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ def _write_export(the_tarfile, resource, dest_dir=None):
temp_file.write("[")

def process_batch(batch):
dataset = resource.export(batch)
model = resource.queryset.model
queryset = model.objects.filter(pk__in=batch)
dataset = resource.export(queryset)
# Strip "[" and "]" as we are writing the dataset in batch
temp_file.write(dataset.json.lstrip("[").rstrip("]"))

offset = 0
first_loop = True
while True:
batch = list(resource.queryset[offset : offset + EXPORT_BATCH_SIZE])
if not batch:
break
offset += EXPORT_BATCH_SIZE
resource_pks = resource.queryset.values_list("pk", flat=True)
for offset in range(0, len(resource_pks), EXPORT_BATCH_SIZE):
batch = resource_pks[offset : offset + EXPORT_BATCH_SIZE]

if not first_loop:
temp_file.write(", ")
Expand Down

0 comments on commit 664ce50

Please sign in to comment.