Skip to content

Commit

Permalink
fix: init storages in order (#6346)
Browse files Browse the repository at this point in the history
  • Loading branch information
0daysseus authored Apr 19, 2024
1 parent 793a4ea commit 0c9dcec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/bootstrap/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions internal/db/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package db

import (
"fmt"
"sort"

"github.com/alist-org/alist/v3/internal/model"
"github.com/pkg/errors"
Expand Down Expand Up @@ -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
}

0 comments on commit 0c9dcec

Please sign in to comment.