@cryptotaxi247 / kubo / commits / 19730d46e

Sort mountpoints.

License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed Jul 16, 2017 at 14:07 UTC 19730d46eafad8387f56296bb784f0e5c5a0770f
2 files changed +17 -10
repo/fsrepo/config_test.go
+12 -10
@@ -10,12 +10,24 @@ import (
10 config "github.com/ipfs/go-ipfs/repo/config"
11 )
12
13 +// note: to test sorting of the mountpoints in the disk spec they are
14 +// specified out of order in the test config
15 var defaultConfig = []byte(`{
16 "StorageMax": "10GB",
17 "StorageGCWatermark": 90,
18 "GCPeriod": "1h",
19 "Spec": {
20 "mounts": [
21 + {
22 + "child": {
23 + "compression": "none",
24 + "path": "datastore",
25 + "type": "levelds"
26 + },
27 + "mountpoint": "/",
28 + "prefix": "leveldb.datastore",
29 + "type": "measure"
30 + },
31 {
32 "child": {
33 "path": "blocks",
@@ -26,16 +38,6 @@ var defaultConfig = []byte(`{
38 "mountpoint": "/blocks",
39 "prefix": "flatfs.datastore",
40 "type": "measure"
29 - },
30 - {
31 - "child": {
32 - "compression": "none",
33 - "path": "datastore",
34 - "type": "levelds"
35 - },
36 - "mountpoint": "/",
37 - "prefix": "leveldb.datastore",
38 - "type": "measure"
41 }
42 ],
43 "type": "mount"
repo/fsrepo/datastores.go
+5
@@ -5,6 +5,7 @@ import (
5 "encoding/json"
6 "fmt"
7 "path/filepath"
8 + "sort"
9
10 repo "github.com/ipfs/go-ipfs/repo"
11
@@ -114,6 +115,10 @@ func MountDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error
115 prefix: ds.NewKey(prefix.(string)),
116 })
117 }
118 + sort.Slice(res.mounts,
119 + func(i, j int) bool {
120 + return res.mounts[i].prefix.String() > res.mounts[j].prefix.String()
121 + })
122
123 return &res, nil
124 }