|
|
@@ -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 { |
|
|
|