diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2023-07-03 15:33:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-03 15:33:28 +0200 |
commit | c890454769562e0ec2978e123aaf3d9a43e5ef4f (patch) | |
tree | a152b5a0356a3da4f83083c5e7fc87214f8bd251 /modules | |
parent | f1cb461c1fb23b68ae34ada2de6bad3bfa6ceeca (diff) | |
download | gitea-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 'modules')
-rw-r--r-- | modules/packages/content_store.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/packages/content_store.go b/modules/packages/content_store.go index 1181fa4d52..da93e6cf6b 100644 --- a/modules/packages/content_store.go +++ b/modules/packages/content_store.go @@ -5,9 +5,11 @@ package packages import ( "io" + "net/url" "path" "strings" + "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/modules/util" ) @@ -31,6 +33,14 @@ func (s *ContentStore) Get(key BlobHash256Key) (storage.Object, error) { return s.store.Open(KeyToRelativePath(key)) } +func (s *ContentStore) ShouldServeDirect() bool { + return setting.Packages.Storage.MinioConfig.ServeDirect +} + +func (s *ContentStore) GetServeDirectURL(key BlobHash256Key, filename string) (*url.URL, error) { + return s.store.URL(KeyToRelativePath(key), filename) +} + // FIXME: Workaround to be removed in v1.20 // https://github.com/go-gitea/gitea/issues/19586 func (s *ContentStore) Has(key BlobHash256Key) error { |