fix ipfs1 mount so it will compile
Juan Batiz-Benet committed
Nov 16, 2014 at 02:30 UTC
13c390b0b5355b24ddff9d0b9a8c3ebf327e77d9
1 file changed
+32
-32
cmd/ipfs/mount_unix.go
+32
-32
@@ -3,13 +3,12 @@
3
package main
4
5
import (
6
- "fmt"
7
-
6
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
7
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
8
9
core "github.com/jbenet/go-ipfs/core"
10
ipns "github.com/jbenet/go-ipfs/fuse/ipns"
11
+ mount "github.com/jbenet/go-ipfs/fuse/mount"
12
rofs "github.com/jbenet/go-ipfs/fuse/readonly"
13
)
14
@@ -48,52 +47,53 @@ func mountCmd(c *commander.Command, inp []string) error {
47
if val, ok := c.Flag.Lookup("f").Value.Get().(string); ok && val != "" {
48
fsdir = val
49
}
51
- fsdone := mountIpfs(cc.node, fsdir)
50
51
// get default mount points
52
nsdir := cc.node.Config.Mounts.IPNS
53
if val, ok := c.Flag.Lookup("n").Value.Get().(string); ok && val != "" {
54
nsdir = val
55
}
58
- nsdone := mountIpns(cc.node, nsdir, fsdir)
59
-
60
- // wait till mounts are done.
61
- err1 := <-fsdone
62
- err2 := <-nsdone
56
64
- if err1 != nil {
65
- return err1
66
- }
67
- return err2
57
+ return doMount(cc.node, fsdir, nsdir)
58
}
59
70
-func mountIpfs(node *core.IpfsNode, fsdir string) <-chan error {
71
- done := make(chan error)
72
- fmt.Printf("mounting ipfs at %s\n", fsdir)
60
+func doMount(node *core.IpfsNode, fsdir, nsdir string) error {
61
74
- go func() {
75
- err := rofs.Mount(node, fsdir)
76
- done <- err
77
- close(done)
78
- }()
62
+ // this sync stuff is so that both can be mounted simultaneously.
63
+ var fsmount mount.Mount
64
+ var nsmount mount.Mount
65
+ var err1 error
66
+ var err2 error
67
80
- return done
81
-}
68
+ done := make(chan struct{})
69
83
-func mountIpns(node *core.IpfsNode, nsdir, fsdir string) <-chan error {
84
- if nsdir == "" {
85
- return nil
86
- }
87
- done := make(chan error)
88
- fmt.Printf("mounting ipns at %s\n", nsdir)
70
+ go func() {
71
+ fsmount, err1 = rofs.Mount(node, fsdir)
72
+ done <- struct{}{}
73
+ }()
74
75
go func() {
91
- err := ipns.Mount(node, nsdir, fsdir)
92
- done <- err
93
- close(done)
76
+ nsmount, err2 = ipns.Mount(node, nsdir, fsdir)
77
+ done <- struct{}{}
78
}()
79
96
- return done
80
+ <-done
81
+ <-done
82
+
83
+ if err1 != nil || err2 != nil {
84
+ fsmount.Close()
85
+ nsmount.Close()
86
+ if err1 != nil {
87
+ return err1
88
+ } else {
89
+ return err2
90
+ }
91
+ }
92
+
93
+ // setup node state, so that it can be cancelled
94
+ node.Mounts.Ipfs = fsmount
95
+ node.Mounts.Ipns = nsmount
96
+ return nil
97
}
98
99
var platformFuseChecks = func() error {