From ef9d1e9002a1f791e5ee6d0c55d1524a8e9a1777 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 12 Dec 2024 00:49:06 +0800 Subject: [PATCH] Add standard-compliant route to serve outdated R packages (#32783) (#32789) Backport #32783 by Sebastian-T-T The R package repository currently does not have support for older versions of packages which should be stored in a separate /Archive router. This PR remedies that by adding a new path router. Fixes #32782 Co-authored-by: Sebastian T. T. <109338575+Sebastian-T-T@users.noreply.github.com> --- routers/api/packages/api.go | 1 + tests/integration/api_packages_cran_test.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go index a3501a9455..623e37aaec 100644 --- a/routers/api/packages/api.go +++ b/routers/api/packages/api.go @@ -314,6 +314,7 @@ func CommonRoutes() *web.Route { r.Get("/PACKAGES", cran.EnumerateSourcePackages) r.Get("/PACKAGES{format}", cran.EnumerateSourcePackages) r.Get("/{filename}", cran.DownloadSourcePackageFile) + r.Get("/Archive/{packagename}/{filename}", cran.DownloadSourcePackageFile) }) r.Put("", reqPackageAccess(perm.AccessModeWrite), cran.UploadSourcePackageFile) }) diff --git a/tests/integration/api_packages_cran_test.go b/tests/integration/api_packages_cran_test.go index d307e87d4e..667ba0908c 100644 --- a/tests/integration/api_packages_cran_test.go +++ b/tests/integration/api_packages_cran_test.go @@ -115,6 +115,14 @@ func TestPackageCran(t *testing.T) { MakeRequest(t, req, http.StatusOK) }) + t.Run("DownloadArchived", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req := NewRequest(t, "GET", fmt.Sprintf("%s/src/contrib/Archive/%s/%s_%s.tar.gz", url, packageName, packageName, packageVersion)). + AddBasicAuth(user.Name) + MakeRequest(t, req, http.StatusOK) + }) + t.Run("Enumerate", func(t *testing.T) { defer tests.PrintCurrentTest(t)()