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

Sort mountpoints.

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