aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/packages/maven
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-07-03 15:33:28 +0200
committerGitHub <noreply@github.com>2023-07-03 15:33:28 +0200
commitc890454769562e0ec2978e123aaf3d9a43e5ef4f (patch)
treea152b5a0356a3da4f83083c5e7fc87214f8bd251 /routers/api/packages/maven
parentf1cb461c1fb23b68ae34ada2de6bad3bfa6ceeca (diff)
downloadgitea-c890454769562e0ec2978e123aaf3d9a43e5ef4f.tar.gz
gitea-c890454769562e0ec2978e123aaf3d9a43e5ef4f.zip
Add direct serving of package content (#25543)
Fixes #24723 Direct serving of content aka HTTP redirect is not mentioned in any of the package registry specs but lots of official registries do that so it should be supported by the usual clients.
Diffstat (limited to 'routers/api/packages/maven')
-rw-r--r--routers/api/packages/maven/maven.go12
1 files changed, 3 insertions, 9 deletions
diff --git a/routers/api/packages/maven/maven.go b/routers/api/packages/maven/maven.go
index dd270ff0ed..215cfa7e1f 100644
--- a/routers/api/packages/maven/maven.go
+++ b/routers/api/packages/maven/maven.go
@@ -210,21 +210,15 @@ func servePackageFile(ctx *context.Context, params parameters, serveContent bool
return
}
- s, err := packages_module.NewContentStore().Get(packages_module.BlobHash256Key(pb.HashSHA256))
+ s, u, _, err := packages_service.GetPackageBlobStream(ctx, pf, pb)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
- }
- defer s.Close()
-
- if pf.IsLead {
- if err := packages_model.IncrementDownloadCounter(ctx, pv.ID); err != nil {
- log.Error("Error incrementing download counter: %v", err)
- }
+ return
}
opts.Filename = pf.Name
- ctx.ServeContent(s, opts)
+ helper.ServePackageFile(ctx, s, u, pf, opts)
}
// UploadPackageFile adds a file to the package. If the package does not exist, it gets created.