fix: init storages in order (#6346)

pull/6397/head
jack roble 2024-04-19 05:22:16 -04:00 committed by GitHub
parent 793a4ea6ca
commit 0c9dcec9cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -21,8 +21,8 @@ func LoadStorages() {
if err != nil {
utils.Log.Errorf("failed get enabled storages: %+v", err)
} else {
utils.Log.Infof("success load storage: [%s], driver: [%s]",
storages[i].MountPath, storages[i].Driver)
utils.Log.Infof("success load storage: [%s], driver: [%s], order: [%d]",
storages[i].MountPath, storages[i].Driver, storages[i].Order)
}
}
conf.StoragesLoaded = true

View File

@ -2,6 +2,7 @@ package db
import (
"fmt"
"sort"
"github.com/alist-org/alist/v3/internal/model"
"github.com/pkg/errors"
@ -65,5 +66,8 @@ func GetEnabledStorages() ([]model.Storage, error) {
if err := db.Where(fmt.Sprintf("%s = ?", columnName("disabled")), false).Find(&storages).Error; err != nil {
return nil, errors.WithStack(err)
}
sort.Slice(storages, func(i, j int) bool {
return storages[i].Order < storages[j].Order
})
return storages, nil
}