chore(storage): common sorting for all servers

This commit is contained in:
Quentin McGaw
2022-06-06 01:57:44 +00:00
parent f53f0cfffd
commit 1216326867
48 changed files with 1319 additions and 1795 deletions

View File

@@ -4,6 +4,9 @@ import (
"encoding/json"
"os"
"path/filepath"
"sort"
"github.com/qdm12/gluetun/internal/models"
)
// FlushToFile flushes the merged servers data to the file
@@ -31,6 +34,10 @@ func (s *Storage) flushToFile(path string) error {
encoder := json.NewEncoder(file)
encoder.SetIndent("", " ")
for _, obj := range s.mergedServers.ProviderToServers {
sort.Sort(models.SortableServers(obj.Servers))
}
err = encoder.Encode(&s.mergedServers)
if err != nil {
_ = file.Close()