Skip to content

Commit 486ecc8

Browse files
committed
Fix lint
1 parent aa19e02 commit 486ecc8

File tree

3 files changed

+3
-29
lines changed

3 files changed

+3
-29
lines changed

routers/api/v1/repo/file.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
api "code.gitea.io/gitea/modules/structs"
1919
"code.gitea.io/gitea/modules/web"
2020
"code.gitea.io/gitea/routers/common"
21+
"code.gitea.io/gitea/routers/web/repo"
2122
)
2223

2324
// GetRawFile get a file by path on a repository
@@ -126,7 +127,7 @@ func GetArchive(ctx *context.APIContext) {
126127
ctx.Repo.GitRepo = gitRepo
127128
defer gitRepo.Close()
128129

129-
common.Download(ctx.Context)
130+
repo.Download(ctx.Context)
130131
}
131132

132133
// GetEditorconfig get editor config of a repository

routers/common/repo.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package common
77
import (
88
"fmt"
99
"io"
10-
"net/http"
1110
"path"
1211
"path/filepath"
1312
"strings"
@@ -19,7 +18,6 @@ import (
1918
"code.gitea.io/gitea/modules/log"
2019
"code.gitea.io/gitea/modules/setting"
2120
"code.gitea.io/gitea/modules/typesniffer"
22-
"code.gitea.io/gitea/services/archiver"
2321
)
2422

2523
// ServeBlob download a git.Blob
@@ -41,30 +39,6 @@ func ServeBlob(ctx *context.Context, blob *git.Blob) error {
4139
return ServeData(ctx, ctx.Repo.TreePath, blob.Size(), dataRc)
4240
}
4341

44-
// Download an archive of a repository
45-
func Download(ctx *context.Context) {
46-
uri := ctx.Params("*")
47-
aReq := archiver.DeriveRequestFrom(ctx, uri)
48-
49-
if aReq == nil {
50-
ctx.Error(http.StatusNotFound)
51-
return
52-
}
53-
54-
downloadName := ctx.Repo.Repository.Name + "-" + aReq.GetArchiveName()
55-
complete := aReq.IsComplete()
56-
if !complete {
57-
aReq = archiver.ArchiveRepository(aReq)
58-
complete = aReq.WaitForCompletion(ctx)
59-
}
60-
61-
if complete {
62-
ctx.ServeFile(aReq.GetArchivePath(), downloadName)
63-
} else {
64-
ctx.Error(http.StatusNotFound)
65-
}
66-
}
67-
6842
// ServeData download file from io.Reader
6943
func ServeData(ctx *context.Context, name string, size int64, reader io.Reader) error {
7044
buf := make([]byte, 1024)

routers/web/web.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"code.gitea.io/gitea/modules/validation"
2323
"code.gitea.io/gitea/modules/web"
2424
"code.gitea.io/gitea/routers/api/v1/misc"
25-
"code.gitea.io/gitea/routers/common"
2625
"code.gitea.io/gitea/routers/web/admin"
2726
"code.gitea.io/gitea/routers/web/dev"
2827
"code.gitea.io/gitea/routers/web/events"
@@ -888,7 +887,7 @@ func RegisterRoutes(m *web.Route) {
888887
}, context.RepoRef(), repo.MustBeNotEmpty, context.RequireRepoReaderOr(models.UnitTypeCode))
889888

890889
m.Group("/archive", func() {
891-
m.Get("/*", common.Download)
890+
m.Get("/*", repo.Download)
892891
m.Post("/*", repo.InitiateDownload)
893892
}, repo.MustBeNotEmpty, reqRepoCodeReader)
894893

0 commit comments

Comments
 (0)