Skip to content

Commit 9f48582

Browse files
committed
dedup downloadName
1 parent d58de54 commit 9f48582

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

routers/api/v1/repo/file.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ func archiveDownload(ctx *context.APIContext) {
316316
aReq.CommitID,
317317
))
318318

319-
if setting.Repository.StreamArchives {
320-
downloadName := ctx.Repo.Repository.Name + "-" + aReq.GetArchiveName()
319+
downloadName := ctx.Repo.Repository.Name + "-" + aReq.GetArchiveName()
321320

321+
if setting.Repository.StreamArchives {
322322
ctx.SetServeHeaders(&context.ServeHeaderOptions{
323323
Filename: downloadName,
324324
})
@@ -335,12 +335,10 @@ func archiveDownload(ctx *context.APIContext) {
335335
return
336336
}
337337

338-
download(ctx, aReq.GetArchiveName(), archiver)
338+
download(ctx, downloadName, archiver)
339339
}
340340

341-
func download(ctx *context.APIContext, archiveName string, archiver *repo_model.RepoArchiver) {
342-
downloadName := ctx.Repo.Repository.Name + "-" + archiveName
343-
341+
func download(ctx *context.APIContext, downloadName string, archiver *repo_model.RepoArchiver) {
344342
rPath := archiver.RelativePath()
345343
if setting.RepoArchive.Storage.ServeDirect() {
346344
// If we have a signed url (S3, object storage), redirect to this directly.

routers/web/repo/repo.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ func Download(ctx *context.Context) {
386386
aReq.CommitID,
387387
))
388388

389-
if setting.Repository.StreamArchives {
390-
downloadName := ctx.Repo.Repository.Name + "-" + aReq.GetArchiveName()
389+
downloadName := ctx.Repo.Repository.Name + "-" + aReq.GetArchiveName()
391390

391+
if setting.Repository.StreamArchives {
392392
ctx.SetServeHeaders(&context.ServeHeaderOptions{
393393
Filename: downloadName,
394394
})
@@ -405,12 +405,10 @@ func Download(ctx *context.Context) {
405405
return
406406
}
407407

408-
download(ctx, aReq.GetArchiveName(), archiver)
408+
download(ctx, downloadName, archiver)
409409
}
410410

411-
func download(ctx *context.Context, archiveName string, archiver *repo_model.RepoArchiver) {
412-
downloadName := ctx.Repo.Repository.Name + "-" + archiveName
413-
411+
func download(ctx *context.Context, downloadName string, archiver *repo_model.RepoArchiver) {
414412
rPath := archiver.RelativePath()
415413
if setting.RepoArchive.Storage.ServeDirect() {
416414
// If we have a signed url (S3, object storage), redirect to this directly.

0 commit comments

Comments
 (0)