提交 a97639a7 作者: Jeromy

dont create ipnsfs filesystem until its needed

License: MIT
Signed-off-by: 's avatarJeromy <jeromyj@gmail.com>
上级 0f906596
...@@ -38,7 +38,6 @@ import ( ...@@ -38,7 +38,6 @@ import (
routing "github.com/ipfs/go-ipfs/routing" routing "github.com/ipfs/go-ipfs/routing"
dht "github.com/ipfs/go-ipfs/routing/dht" dht "github.com/ipfs/go-ipfs/routing/dht"
kb "github.com/ipfs/go-ipfs/routing/kbucket"
nilrouting "github.com/ipfs/go-ipfs/routing/none" nilrouting "github.com/ipfs/go-ipfs/routing/none"
offroute "github.com/ipfs/go-ipfs/routing/offline" offroute "github.com/ipfs/go-ipfs/routing/offline"
...@@ -162,15 +161,6 @@ func NewIPFSNode(ctx context.Context, option ConfigOption) (*IpfsNode, error) { ...@@ -162,15 +161,6 @@ func NewIPFSNode(ctx context.Context, option ConfigOption) (*IpfsNode, error) {
} }
node.Resolver = &path.Resolver{DAG: node.DAG} node.Resolver = &path.Resolver{DAG: node.DAG}
// Setup the mutable ipns filesystem structure
if node.OnlineMode() {
fs, err := ipnsfs.NewFilesystem(ctx, node.DAG, node.Namesys, node.Pinning, node.PrivateKey)
if err != nil && err != kb.ErrLookupFailure {
return nil, err
}
node.IpnsFs = fs
}
success = true success = true
return node, nil return node, nil
} }
......
...@@ -6,6 +6,7 @@ package ipns ...@@ -6,6 +6,7 @@ package ipns
import ( import (
core "github.com/ipfs/go-ipfs/core" core "github.com/ipfs/go-ipfs/core"
mount "github.com/ipfs/go-ipfs/fuse/mount" mount "github.com/ipfs/go-ipfs/fuse/mount"
ipnsfs "github.com/ipfs/go-ipfs/ipnsfs"
) )
// Mount mounts ipns at a given location, and returns a mount.Mount instance. // Mount mounts ipns at a given location, and returns a mount.Mount instance.
...@@ -13,6 +14,14 @@ func Mount(ipfs *core.IpfsNode, ipnsmp, ipfsmp string) (mount.Mount, error) { ...@@ -13,6 +14,14 @@ func Mount(ipfs *core.IpfsNode, ipnsmp, ipfsmp string) (mount.Mount, error) {
cfg := ipfs.Repo.Config() cfg := ipfs.Repo.Config()
allow_other := cfg.Mounts.FuseAllowOther allow_other := cfg.Mounts.FuseAllowOther
if ipfs.IpnsFs == nil {
fs, err := ipnsfs.NewFilesystem(ipfs.Context(), ipfs.DAG, ipfs.Namesys, ipfs.Pinning, ipfs.PrivateKey)
if err != nil {
return nil, err
}
ipfs.IpnsFs = fs
}
fsys, err := NewFileSystem(ipfs, ipfs.PrivateKey, ipfsmp, ipnsmp) fsys, err := NewFileSystem(ipfs, ipfs.PrivateKey, ipfsmp, ipnsmp)
if err != nil { if err != nil {
return nil, err return nil, err
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论