Skip to content

Commit

Permalink
Sort mountpoints.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina authored and whyrusleeping committed Sep 3, 2017
1 parent 1f8723d commit 19730d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
22 changes: 12 additions & 10 deletions repo/fsrepo/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,24 @@ import (
config "github.com/ipfs/go-ipfs/repo/config"
)

// note: to test sorting of the mountpoints in the disk spec they are
// specified out of order in the test config
var defaultConfig = []byte(`{
"StorageMax": "10GB",
"StorageGCWatermark": 90,
"GCPeriod": "1h",
"Spec": {
"mounts": [
{
"child": {
"compression": "none",
"path": "datastore",
"type": "levelds"
},
"mountpoint": "/",
"prefix": "leveldb.datastore",
"type": "measure"
},
{
"child": {
"path": "blocks",
Expand All @@ -26,16 +38,6 @@ var defaultConfig = []byte(`{
"mountpoint": "/blocks",
"prefix": "flatfs.datastore",
"type": "measure"
},
{
"child": {
"compression": "none",
"path": "datastore",
"type": "levelds"
},
"mountpoint": "/",
"prefix": "leveldb.datastore",
"type": "measure"
}
],
"type": "mount"
Expand Down
5 changes: 5 additions & 0 deletions repo/fsrepo/datastores.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"path/filepath"
"sort"

repo "github.com/ipfs/go-ipfs/repo"

Expand Down Expand Up @@ -114,6 +115,10 @@ func MountDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error
prefix: ds.NewKey(prefix.(string)),
})
}
sort.Slice(res.mounts,
func(i, j int) bool {
return res.mounts[i].prefix.String() > res.mounts[j].prefix.String()
})

return &res, nil
}
Expand Down

0 comments on commit 19730d4

Please sign in to comment.