Extract folder

This commit is contained in:
微凉
2022-01-16 16:38:41 +08:00
parent e952f1c243
commit cfb51e9f80
5 changed files with 32 additions and 15 deletions

View File

@ -25,14 +25,6 @@ func SortFiles(files []File, account *Account) {
return
}
sort.Slice(files, func(i, j int) bool {
if files[i].IsDir() || files[j].IsDir() {
if !files[i].IsDir() {
return false
}
if !files[j].IsDir() {
return true
}
}
switch account.OrderBy {
case "name":
{
@ -59,6 +51,24 @@ func SortFiles(files []File, account *Account) {
})
}
func ExtractFolder(files []File, account *Account) {
if account.ExtractFolder == "" {
return
}
front := account.ExtractFolder == "front"
sort.Slice(files, func(i, j int) bool {
if files[i].IsDir() || files[j].IsDir() {
if !files[i].IsDir() {
return !front
}
if !files[j].IsDir() {
return front
}
}
return false
})
}
func (f File) GetSize() uint64 {
return uint64(f.Size)
}