Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror Plugin: Disable automatic gzip decompression for syncs #55

Merged
merged 1 commit into from
Apr 30, 2024
Merged
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
11 changes: 10 additions & 1 deletion internal/plugins/mirror/pkg/mirrorrepository/mirrorsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type MirrorSyncer struct {
configID uint64
parallelism int
upstreamRepository string

client *http.Client
}

func NewMirrorSyncer(h *Handler, config mirrorConfig, configID uint64, parallelism int) (*MirrorSyncer, error) {
Expand All @@ -49,6 +51,13 @@ func NewMirrorSyncer(h *Handler, config mirrorConfig, configID uint64, paralleli
configID: configID,
parallelism: parallelism,
upstreamRepository: path.Join("artifacts/mirror", repository),
client: &http.Client{
Transport: &http.Transport{
// Disable compression handling so compressed
// files are preserved as they are when synchronized.
DisableCompression: true,
},
},
}, nil
}

Expand Down Expand Up @@ -127,7 +136,7 @@ func (s *MirrorSyncer) filePush(remoteFile *mirrordb.RepositoryFile) error {
return err
}

resp, err := http.DefaultClient.Do(req)
resp, err := s.client.Do(req)
if err != nil {
s.h.logger.Error("Failed to fetch file", "file", remoteFile.Name, "error", err)
return err
Expand Down
11 changes: 10 additions & 1 deletion internal/plugins/mirror/pkg/mirrorrepository/plansync.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type PlanSyncer struct {
parallelism int

plan *rsync.SyncPlan

client *http.Client
}

func NewPlanSyncer(h *Handler, config mirrorConfig, configID uint64, parallelism int, plan *rsync.SyncPlan) *PlanSyncer {
Expand All @@ -39,6 +41,13 @@ func NewPlanSyncer(h *Handler, config mirrorConfig, configID uint64, parallelism
configID: configID,
parallelism: parallelism,
plan: plan,
client: &http.Client{
Transport: &http.Transport{
// Disable compression handling so compressed
// files are preserved as they are when synchronized.
DisableCompression: true,
},
},
}
}

Expand All @@ -52,7 +61,7 @@ func (s *PlanSyncer) filePush(remoteFile rsync.FileInfo) error {
return err
}

resp, err := http.DefaultClient.Do(req)
resp, err := s.client.Do(req)
if err != nil {
s.h.logger.Error("Failed to fetch file", "file", string(remoteFile.Path), "error", err)
return err
Expand Down
Loading