mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 02:30:39 +08:00
Merge pull request #3749 from ipfs/fix/filestore/enabled-check
fix: filestore silently being skipped on add if it wasn't enabled
This commit is contained in:
@ -1,23 +1,24 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/ipfs/go-ipfs/core/coreunix"
|
||||
"gx/ipfs/QmeWjRodbcZFKe5tMN7poEx3izym6osrLSnTLf9UjJZBbs/pb"
|
||||
|
||||
bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
|
||||
blockservice "github.com/ipfs/go-ipfs/blockservice"
|
||||
cmds "github.com/ipfs/go-ipfs/commands"
|
||||
files "github.com/ipfs/go-ipfs/commands/files"
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
"github.com/ipfs/go-ipfs/core/coreunix"
|
||||
offline "github.com/ipfs/go-ipfs/exchange/offline"
|
||||
dag "github.com/ipfs/go-ipfs/merkledag"
|
||||
dagtest "github.com/ipfs/go-ipfs/merkledag/test"
|
||||
mfs "github.com/ipfs/go-ipfs/mfs"
|
||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||
|
||||
u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util"
|
||||
"gx/ipfs/QmeWjRodbcZFKe5tMN7poEx3izym6osrLSnTLf9UjJZBbs/pb"
|
||||
)
|
||||
|
||||
// Error indicating the max depth has been exceded.
|
||||
@ -128,6 +129,12 @@ You can now refer to the added file in a gateway, like so:
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
return
|
||||
}
|
||||
|
||||
cfg, err := n.Repo.Config()
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
return
|
||||
}
|
||||
// check if repo will exceed storage limit if added
|
||||
// TODO: this doesn't handle the case if the hashed file is already in blocks (deduplicated)
|
||||
// TODO: conditional GC is disabled due to it is somehow not possible to pass the size to the daemon
|
||||
@ -148,6 +155,12 @@ You can now refer to the added file in a gateway, like so:
|
||||
nocopy, _, _ := req.Option(noCopyOptionName).Bool()
|
||||
fscache, _, _ := req.Option(fstoreCacheOptionName).Bool()
|
||||
|
||||
if nocopy && !cfg.Experimental.FilestoreEnabled {
|
||||
res.SetError(errors.New("filestore is not enabled, see https://git.io/vy4XN"),
|
||||
cmds.ErrClient)
|
||||
return
|
||||
}
|
||||
|
||||
if nocopy && !rbset {
|
||||
rawblks = true
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ assert_repo_size_less_than() {
|
||||
|
||||
test_expect_success "check repo size" '
|
||||
test "$(get_repo_size)" -lt "$expval" ||
|
||||
(get_repo_size && false)
|
||||
test_fsh get_repo_size
|
||||
'
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ assert_repo_size_greater_than() {
|
||||
|
||||
test_expect_success "check repo size" '
|
||||
test "$(get_repo_size)" -gt "$expval" ||
|
||||
(get_repo_size && false)
|
||||
test_fsh get_repo_size
|
||||
'
|
||||
}
|
||||
|
||||
@ -68,6 +68,12 @@ init_ipfs_filestore() {
|
||||
|
||||
test_init_ipfs
|
||||
|
||||
test_expect_success "nocopy add errors and has right message" '
|
||||
test_must_fail ipfs add --nocopy -r somedir 2> add_out &&
|
||||
grep "filestore is not enabled" add_out
|
||||
'
|
||||
|
||||
|
||||
test_expect_success "enable filestore config setting" '
|
||||
ipfs config --json Experimental.FilestoreEnabled true
|
||||
'
|
||||
|
Reference in New Issue
Block a user