Browse Source

fix-bug

tags/v1.22.3.2^2
liuzx 3 years ago
parent
commit
e3004c488c
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      models/attachment.go

+ 9
- 1
models/attachment.go View File

@@ -9,6 +9,7 @@ import (
"fmt"
"io"
"path"
"strings"

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/obs"
@@ -70,6 +71,7 @@ type AttachmentsOptions struct {
NeedIsPrivate bool
IsPrivate bool
NeedRepoInfo bool
Keyword string
}

func (a *Attachment) AfterUpdate() {
@@ -554,8 +556,14 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) {

var count int64
var err error
if (opts.Type) >= 0 {
if len(opts.Keyword) == 0 {
count, err = sess.Where(cond).Count(new(Attachment))
} else {
lowerKeyWord := strings.ToLower(opts.Keyword)

cond = cond.And(builder.Or(builder.Like{"LOWER(attachment.name)", lowerKeyWord}))
count, err = sess.Table(&Attachment{}).Where(cond).Count(new(AttachmentInfo))

}

if err != nil {


Loading…
Cancel
Save