commands(add): fix `ipfs add --nocopy URL` without enabling the filestore
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Mar 28, 2019 at 19:44 UTC
470d6ba7a80245b8a68277e3945e4d6fa6051450
2 files changed
+14
-4
core/coreapi/unixfs.go
+2
-3
@@ -5,7 +5,6 @@ import (
5
"fmt"
6
7
"github.com/ipfs/go-ipfs/core"
8
- "github.com/ipfs/go-ipfs/filestore"
8
9
"github.com/ipfs/go-ipfs/core/coreunix"
10
@@ -49,8 +48,8 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options
48
// return
49
//}
50
52
- if settings.NoCopy && !cfg.Experimental.FilestoreEnabled {
53
- return nil, filestore.ErrFilestoreNotEnabled
51
+ if settings.NoCopy && !(cfg.Experimental.FilestoreEnabled || cfg.Experimental.UrlstoreEnabled) {
52
+ return nil, fmt.Errorf("either the filestore or the urlstore must be enabled to use nocopy, see: https://git.io/vNItf")
53
}
54
55
addblockstore := api.blockstore
test/sharness/t0270-filestore.sh
+12
-1
@@ -68,13 +68,24 @@ init_ipfs_filestore() {
68
69
test_init_ipfs
70
71
+ # Check the _early_ error message
72
test_expect_success "nocopy add errors and has right message" '
73
test_must_fail ipfs add --nocopy -r somedir 2> add_out &&
73
- grep "filestore is not enabled" add_out
74
+ grep "either the filestore or the urlstore must be enabled" add_out
75
+ '
76
+
77
+ test_expect_success "enable urlstore config setting" '
78
+ ipfs config --json Experimental.UrlstoreEnabled true
79
'
80
81
+ # Check the _late_ error message
82
+ test_expect_success "nocopy add errors and has right message when the urlstore is enabled" '
83
+ test_must_fail ipfs add --nocopy -r somedir 2> add_out &&
84
+ grep "filestore is not enabled" add_out
85
+ '
86
87
test_expect_success "enable filestore config setting" '
88
+ ipfs config --json Experimental.UrlstoreEnabled true &&
89
ipfs config --json Experimental.FilestoreEnabled true
90
'
91
}