Skip to content

Commit

Permalink
Check for existing parent commits in import-all
Browse files Browse the repository at this point in the history
closes #279

(cherry picked from commit 38f6f5f)
  • Loading branch information
lubosmj committed Sep 11, 2023
1 parent 24089b4 commit 9ab7493
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES/279.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Made the import facility to accept tarballs with already imported parent commits.
19 changes: 14 additions & 5 deletions pulp_ostree/app/tasks/importing.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,17 @@ async def parse_ref(self, name, ref_commit_checksum, has_referenced_parent=False
# and this state is still considered valid
return parent_checksum, ref_commit_dc
else:
raise ValueError(
gettext("The parent commit '{}' could not be loaded").format(parent_checksum)
)
try:
parent_commit = await OstreeCommit.objects.aget(checksum=parent_checksum)
except OstreeCommit.DoesNotExist:
raise ValueError(
gettext("The parent commit '{}' could not be loaded").format(
parent_checksum
)
)
else:
await self.copy_from_storage_to_tmp(parent_commit, parent_commit.objs)
_, parent_commit, _ = self.repo.load_commit(parent_checksum)

return await self.load_next_commits(parent_commit, parent_checksum, has_referenced_parent)

Expand Down Expand Up @@ -323,9 +331,10 @@ async def run(self):
if self.compute_delta:
num_of_parsed_commits = len(self.commit_dcs)

parent_commit = await OstreeCommit.objects.aget(
commit = await OstreeCommit.objects.select_related("parent_commit").aget(
checksum=ref_commit_checksum
).parent_commit
)
parent_commit = commit.parent_commit
if parent_commit and num_of_parsed_commits == 1:
await self.copy_from_storage_to_tmp(parent_commit, parent_commit.objs)
await self.compute_static_delta(
Expand Down

0 comments on commit 9ab7493

Please sign in to comment.