diff options
author | Abner <abner199709@gmail.com> | 2021-08-22 02:22:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-21 20:22:06 +0200 |
commit | 7844bf1430d5d2701c70ff525b6455c10cb23484 (patch) | |
tree | ff0b86c9e20f765338195c73d5a9b2adb8cbbded /routers | |
parent | 06f82641cb65c88d89bfaeca01f9fc3b32bb76b8 (diff) | |
download | gitea-7844bf1430d5d2701c70ff525b6455c10cb23484.tar.gz gitea-7844bf1430d5d2701c70ff525b6455c10cb23484.zip |
Download lfs in git and web workflow from minio/s3 directly (#16731)
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/download.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/routers/web/repo/download.go b/routers/web/repo/download.go index 6f43d4b839..2307f736ad 100644 --- a/routers/web/repo/download.go +++ b/routers/web/repo/download.go @@ -11,6 +11,8 @@ import ( "code.gitea.io/gitea/modules/httpcache" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/routers/common" ) @@ -47,6 +49,16 @@ func ServeBlobOrLFS(ctx *context.Context, blob *git.Blob) error { if httpcache.HandleGenericETagCache(ctx.Req, ctx.Resp, `"`+pointer.Oid+`"`) { return nil } + + if setting.LFS.ServeDirect { + //If we have a signed url (S3, object storage), redirect to this directly. + u, err := storage.LFS.URL(pointer.RelativePath(), blob.Name()) + if u != nil && err == nil { + ctx.Redirect(u.String()) + return nil + } + } + lfsDataRc, err := lfs.ReadMetaObject(meta.Pointer) if err != nil { return err |