Skip to content

Commit 874b848

Browse files
Add standard-compliant route to serve outdated R packages (#32783)
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. I am a member of a group that loves using Gitea and this bug has been annoying us for a long time. Hope it can be merged in time for Gitea 1.23.0. Any feedback much appreciated. Fixes #32782
1 parent 4814f43 commit 874b848

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

routers/api/packages/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ func CommonRoutes() *web.Router {
358358
r.Get("/PACKAGES", cran.EnumerateSourcePackages)
359359
r.Get("/PACKAGES{format}", cran.EnumerateSourcePackages)
360360
r.Get("/{filename}", cran.DownloadSourcePackageFile)
361+
r.Get("/Archive/{packagename}/{filename}", cran.DownloadSourcePackageFile)
361362
})
362363
r.Put("", reqPackageAccess(perm.AccessModeWrite), cran.UploadSourcePackageFile)
363364
})

tests/integration/api_packages_cran_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ func TestPackageCran(t *testing.T) {
115115
MakeRequest(t, req, http.StatusOK)
116116
})
117117

118+
t.Run("DownloadArchived", func(t *testing.T) {
119+
defer tests.PrintCurrentTest(t)()
120+
121+
req := NewRequest(t, "GET", fmt.Sprintf("%s/src/contrib/Archive/%s/%s_%s.tar.gz", url, packageName, packageName, packageVersion)).
122+
AddBasicAuth(user.Name)
123+
MakeRequest(t, req, http.StatusOK)
124+
})
125+
118126
t.Run("Enumerate", func(t *testing.T) {
119127
defer tests.PrintCurrentTest(t)()
120128

0 commit comments

Comments
 (0)