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 pulp#279
  • Loading branch information
lubosmj committed Aug 28, 2023
1 parent 9f904d9 commit ef6bc6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 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-all facility to accept imports with already imported parent commits.
27 changes: 15 additions & 12 deletions pulp_ostree/app/tasks/importing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import tarfile

from gettext import gettext
from gettext import gettext as _

from pulpcore.plugin.models import Artifact, Repository, ProgressReport
from pulpcore.plugin.stages import (
Expand Down Expand Up @@ -111,9 +111,15 @@ 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(
_("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 @@ -141,9 +147,7 @@ async def load_next_commits(self, parent_commit, checksum, has_referenced_parent
return parent_checksum, commit_dc
else:
raise ValueError(
gettext("The parent commit '{}' could not be loaded").format(
parent_checksum
)
_("The parent commit '{}' could not be loaded").format(parent_checksum)
)
parent_checksum = OSTree.commit_get_parent(parent_commit)

Expand Down Expand Up @@ -193,7 +197,7 @@ def init_repository(self):
self.repo.open()
except GLib.Error:
raise ValueError(
gettext("An invalid path to the repository provided: {}").format(self.repo_name)
_("An invalid path to the repository provided: {}").format(self.repo_name)
)


Expand Down Expand Up @@ -231,7 +235,7 @@ async def run(self):

if last_commit_dc is None:
raise ValueError(
gettext("An invalid ref name in the repository was specified: {}").format(
_("An invalid ref name in the repository was specified: {}").format(
self.ref
)
)
Expand Down Expand Up @@ -306,9 +310,8 @@ async def run(self):
if self.compute_delta:
num_of_parsed_commits = len(self.commit_dcs)

parent_commit = await OstreeCommit.objects.aget(
checksum=ref_commit_checksum
).parent_commit
commit = await OstreeCommit.objects.aget(checksum=ref_commit_checksum)
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 ef6bc6d

Please sign in to comment.