mirror of
1
Fork 0
This commit is contained in:
isotas38 2014-11-02 14:18:37 +09:00
parent 283c81316c
commit 2c28ed8c05
1 changed files with 4 additions and 1 deletions

View File

@ -263,15 +263,18 @@ func Download(ctx *middleware.Context) {
refName string refName string
ext string ext string
archivePath string archivePath string
archiveType git.ArchiveType
) )
switch { switch {
case strings.HasSuffix(uri, ".zip"): case strings.HasSuffix(uri, ".zip"):
ext = ".zip" ext = ".zip"
archivePath = path.Join(ctx.Repo.GitRepo.Path, "archives/zip") archivePath = path.Join(ctx.Repo.GitRepo.Path, "archives/zip")
archiveType = git.ZIP
case strings.HasSuffix(uri, ".tar.gz"): case strings.HasSuffix(uri, ".tar.gz"):
ext = ".tar.gz" ext = ".tar.gz"
archivePath = path.Join(ctx.Repo.GitRepo.Path, "archives/targz") archivePath = path.Join(ctx.Repo.GitRepo.Path, "archives/targz")
archiveType = git.TARGZ
default: default:
ctx.Error(404) ctx.Error(404)
return return
@ -316,7 +319,7 @@ func Download(ctx *middleware.Context) {
archivePath = path.Join(archivePath, base.ShortSha(commit.Id.String())+ext) archivePath = path.Join(archivePath, base.ShortSha(commit.Id.String())+ext)
if !com.IsFile(archivePath) { if !com.IsFile(archivePath) {
if err := commit.CreateArchive(archivePath, git.ZIP); err != nil { if err := commit.CreateArchive(archivePath, archiveType); err != nil {
ctx.Handle(500, "Download -> CreateArchive "+archivePath, err) ctx.Handle(500, "Download -> CreateArchive "+archivePath, err)
return return
} }