|
|
@@ -2,8 +2,9 @@ package repo |
|
|
|
|
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
"io/ioutil" |
|
|
|
"os" |
|
|
|
"path" |
|
|
|
"sort" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
@@ -52,7 +53,7 @@ func DirIndex(ctx *context.Context) { |
|
|
|
dirArray = []string{attachment.Name} |
|
|
|
} |
|
|
|
|
|
|
|
files, err := ioutil.ReadDir(setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + |
|
|
|
files, err := readDir(setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + |
|
|
|
path.Join(uuid[0:1], uuid[1:2], uuid+uuid) + "/" + parentDir) |
|
|
|
if err != nil { |
|
|
|
log.Error("ReadDir failed:", err.Error()) |
|
|
@@ -93,3 +94,19 @@ func DirIndex(ctx *context.Context) { |
|
|
|
|
|
|
|
ctx.HTML(200, tplDirIndex) |
|
|
|
} |
|
|
|
|
|
|
|
// readDir reads the directory named by dirname and returns |
|
|
|
// a list of directory entries sorted by filename. |
|
|
|
func readDir(dirname string) ([]os.FileInfo, error) { |
|
|
|
f, err := os.Open(dirname) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
list, err := f.Readdir(100) |
|
|
|
f.Close() |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
sort.Slice(list, func(i, j int) bool { return list[i].Name() < list[j].Name() }) |
|
|
|
return list, nil |
|
|
|
} |