diff options
author | Unknwon <u@gogs.io> | 2016-08-12 02:29:29 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-14 23:52:24 -0700 |
commit | 15845cb28763c1542556ad61d2aa9735541dbf45 (patch) | |
tree | 94b2053202fcf5270e0697fc37c38203310571ed /routers/repo/upload.go | |
parent | d0a0239bacf02eb004634dfe1bb0a3f7dfe5adb6 (diff) |
Code clean up for new config options
Diffstat (limited to 'routers/repo/upload.go')
-rw-r--r-- | routers/repo/upload.go | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/routers/repo/upload.go b/routers/repo/upload.go index fedf4064..efecc208 100644 --- a/routers/repo/upload.go +++ b/routers/repo/upload.go @@ -24,10 +24,10 @@ const ( func renderUploadSettings(ctx *context.Context) { ctx.Data["RequireDropzone"] = true - ctx.Data["IsUploadEnabled"] = setting.UploadEnabled - ctx.Data["UploadAllowedTypes"] = setting.UploadAllowedTypes - ctx.Data["UploadMaxSize"] = setting.UploadMaxSize - ctx.Data["UploadMaxFiles"] = setting.UploadMaxFiles + ctx.Data["IsUploadEnabled"] = setting.Repository.Upload.Enabled + ctx.Data["UploadAllowedTypes"] = strings.Join(setting.Repository.Upload.AllowedTypes, ",") + ctx.Data["UploadMaxSize"] = setting.Repository.Upload.FileMaxSize + ctx.Data["UploadMaxFiles"] = setting.Repository.Upload.MaxFiles } func UploadFile(ctx *context.Context) { @@ -154,13 +154,8 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) { log.Error(4, "branch.GetCommit(): %v", err) } else { pc := &models.PushCommits{ - Len: 1, - Commits: []*models.PushCommit{&models.PushCommit{ - commit.ID.String(), - commit.Message(), - commit.Author.Email, - commit.Author.Name, - }}, + Len: 1, + Commits: []*models.PushCommit{models.CommitToPushCommit(commit)}, } oldCommitID := ctx.Repo.CommitID newCommitID := commit.ID.String() @@ -184,7 +179,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) { } func UploadFileToServer(ctx *context.Context) { - if !setting.UploadEnabled { + if !setting.Repository.Upload.Enabled { ctx.Error(404, "upload is not enabled") return } @@ -203,10 +198,9 @@ func UploadFileToServer(ctx *context.Context) { } fileType := http.DetectContentType(buf) - if len(setting.UploadAllowedTypes) > 0 { - allowedTypes := strings.Split(setting.UploadAllowedTypes, ",") + if len(setting.Repository.Upload.AllowedTypes) > 0 { allowed := false - for _, t := range allowedTypes { + for _, t := range setting.Repository.Upload.AllowedTypes { t := strings.Trim(t, " ") if t == "*/*" || t == fileType { allowed = true @@ -233,7 +227,7 @@ func UploadFileToServer(ctx *context.Context) { } func RemoveUploadFileFromServer(ctx *context.Context, form auth.RemoveUploadFileForm) { - if !setting.UploadEnabled { + if !setting.Repository.Upload.Enabled { ctx.Error(404, "upload is not enabled") return } |