Fix various problems (#37129)
* Fix #37128 * Manually tested with various cases (issue, pr) X (close, reopen) * Fix #36792 * Fix the comment * Fix #36755 * Add a "sleep 3" * Follow up #36697 * Clarify the "attachment uploading" problem and function call --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
@@ -23,16 +23,16 @@ import (
|
||||
|
||||
// UploadIssueAttachment response for Issue/PR attachments
|
||||
func UploadIssueAttachment(ctx *context.Context) {
|
||||
uploadAttachment(ctx, ctx.Repo.Repository.ID, setting.Attachment.AllowedTypes)
|
||||
uploadAttachment(ctx, ctx.Repo.Repository.ID, attachment.UploadAttachmentForIssue)
|
||||
}
|
||||
|
||||
// UploadReleaseAttachment response for uploading release attachments
|
||||
func UploadReleaseAttachment(ctx *context.Context) {
|
||||
uploadAttachment(ctx, ctx.Repo.Repository.ID, setting.Repository.Release.AllowedTypes)
|
||||
uploadAttachment(ctx, ctx.Repo.Repository.ID, attachment.UploadAttachmentForRelease)
|
||||
}
|
||||
|
||||
// UploadAttachment response for uploading attachments
|
||||
func uploadAttachment(ctx *context.Context, repoID int64, allowedTypes string) {
|
||||
func uploadAttachment(ctx *context.Context, repoID int64, uploadFunc attachment.UploadAttachmentFunc) {
|
||||
if !setting.Attachment.Enabled {
|
||||
ctx.HTTPError(http.StatusNotFound, "attachment is not enabled")
|
||||
return
|
||||
@@ -46,7 +46,7 @@ func uploadAttachment(ctx *context.Context, repoID int64, allowedTypes string) {
|
||||
defer file.Close()
|
||||
|
||||
uploaderFile := attachment.NewLimitedUploaderKnownSize(file, header.Size)
|
||||
attach, err := attachment.UploadAttachmentReleaseSizeLimit(ctx, uploaderFile, allowedTypes, &repo_model.Attachment{
|
||||
attach, err := uploadFunc(ctx, uploaderFile, &repo_model.Attachment{
|
||||
Name: header.Filename,
|
||||
UploaderID: ctx.Doer.ID,
|
||||
RepoID: repoID,
|
||||
@@ -56,7 +56,7 @@ func uploadAttachment(ctx *context.Context, repoID int64, allowedTypes string) {
|
||||
ctx.HTTPError(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.ServerError("UploadAttachmentReleaseSizeLimit", err)
|
||||
ctx.ServerError("uploadAttachment(uploadFunc)", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ func DeleteAttachment(ctx *context.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// GetAttachment serve attachments with the given UUID
|
||||
// ServeAttachment serve attachments with the given UUID
|
||||
func ServeAttachment(ctx *context.Context, uuid string) {
|
||||
attach, err := repo_model.GetAttachmentByUUID(ctx, uuid)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user