diff --git a/internal/plugins/mirror/pkg/mirrorrepository/mirrorsync.go b/internal/plugins/mirror/pkg/mirrorrepository/mirrorsync.go index b11f714..ee21bcf 100644 --- a/internal/plugins/mirror/pkg/mirrorrepository/mirrorsync.go +++ b/internal/plugins/mirror/pkg/mirrorrepository/mirrorsync.go @@ -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) { @@ -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 } @@ -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 diff --git a/internal/plugins/mirror/pkg/mirrorrepository/plansync.go b/internal/plugins/mirror/pkg/mirrorrepository/plansync.go index 8851cec..5458492 100644 --- a/internal/plugins/mirror/pkg/mirrorrepository/plansync.go +++ b/internal/plugins/mirror/pkg/mirrorrepository/plansync.go @@ -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 { @@ -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, + }, + }, } } @@ -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