提交 19730d46 作者: Kevin Atkinson 提交者: Jeromy

Sort mountpoints.

License: MIT
Signed-off-by: 's avatarKevin Atkinson <k@kevina.org>
上级 1f8723d0
......@@ -10,6 +10,8 @@ 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,
......@@ -18,6 +20,16 @@ var defaultConfig = []byte(`{
"mounts": [
{
"child": {
"compression": "none",
"path": "datastore",
"type": "levelds"
},
"mountpoint": "/",
"prefix": "leveldb.datastore",
"type": "measure"
},
{
"child": {
"path": "blocks",
"shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
"sync": true,
......@@ -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"
......
......@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"path/filepath"
"sort"
repo "github.com/ipfs/go-ipfs/repo"
......@@ -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
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论