Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/pulp_file/+remove-double-publish.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed double publish when using autopublish and syncing in mirror mode.
28 changes: 2 additions & 26 deletions pulp_file/app/tasks/synchronizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

import git as gitpython
from gitdb.exc import BadName, BadObject
from django.core.files import File

from pulpcore.plugin.exceptions import SyncError
from pulpcore.plugin.models import Artifact, ProgressReport, Remote, PublishedMetadata
from pulpcore.plugin.models import Artifact, ProgressReport, Remote
from pulpcore.plugin.serializers import RepositoryVersionSerializer
from pulpcore.plugin.stages import (
DeclarativeArtifact,
Expand All @@ -26,16 +25,12 @@
FileContent,
FileGitRemote,
FileRepository,
FilePublication,
)
from pulp_file.manifest import Manifest

log = logging.getLogger(__name__)


metadata_files = []


def synchronize(remote_pk, repository_pk, mirror, url=None):
"""
Sync content from the remote repository.
Expand Down Expand Up @@ -70,24 +65,7 @@ def synchronize(remote_pk, repository_pk, mirror, url=None):
else:
first_stage = FileFirstStage(remote, url)
dv = DeclarativeVersion(first_stage, repository, mirror=mirror, acs=True)
rv = dv.create()
if rv and mirror:
# TODO: this is awful, we really should rewrite the DeclarativeVersion API to
# accomodate this use case
global metadata_files
with FilePublication.create(rv, pass_through=True) as publication:
mdfile_path, relative_path = metadata_files.pop()
PublishedMetadata.create_from_file(
file=File(open(mdfile_path, "rb")),
relative_path=relative_path,
publication=publication,
)
publication.manifest = relative_path
publication.save()

log.info(_("Publication: {publication} created").format(publication=publication.pk))

if rv:
if rv := dv.create():
rv = RepositoryVersionSerializer(instance=rv, context={"request": None}).data

return rv
Expand Down Expand Up @@ -115,7 +93,6 @@ async def run(self):
"""
Build and emit `DeclarativeContent` from the Manifest data.
"""
global metadata_files

deferred_download = self.remote.policy != Remote.IMMEDIATE # Interpret download policy
async with ProgressReport(
Expand All @@ -126,7 +103,6 @@ async def run(self):
downloader = self.remote.get_downloader(url=self.url)
result = await downloader.run()
await pb.aincrement()
metadata_files.append((result.path, self.url.split("/")[-1]))

async with ProgressReport(
message="Parsing Metadata Lines", code="sync.parsing.metadata"
Expand Down
Loading