//collects options and opens the fuse mountpoint func mountFuse(req cmds.Request) error { cfg, err := req.InvocContext().GetConfig() if err != nil { return fmt.Errorf("mountFuse: GetConfig() failed: %s", err) } fsdir, found, err := req.Option(ipfsMountKwd).String() if err != nil { return fmt.Errorf("mountFuse: req.Option(%s) failed: %s", ipfsMountKwd, err) } if !found { fsdir = cfg.Mounts.IPFS } nsdir, found, err := req.Option(ipnsMountKwd).String() if err != nil { return fmt.Errorf("mountFuse: req.Option(%s) failed: %s", ipnsMountKwd, err) } if !found { nsdir = cfg.Mounts.IPNS } node, err := req.InvocContext().ConstructNode() if err != nil { return fmt.Errorf("mountFuse: ConstructNode() failed: %s", err) } err = nodeMount.Mount(node, fsdir, nsdir) if err != nil { return err } fmt.Printf("IPFS mounted at: %s\n", fsdir) fmt.Printf("IPNS mounted at: %s\n", nsdir) return nil }
} if !found { fsdir = cfg.Mounts.IPFS // use default value } // get default mount points nsdir, found, err := req.Option("n").String() if err != nil { res.SetError(err, cmds.ErrNormal) return } if !found { nsdir = cfg.Mounts.IPNS // NB: be sure to not redeclare! } err = nodeMount.Mount(node, fsdir, nsdir) if err != nil { res.SetError(err, cmds.ErrNormal) return } var output config.Mounts output.IPFS = fsdir output.IPNS = nsdir res.SetOutput(&output) }, Type: config.Mounts{}, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { v := res.Output().(*config.Mounts) s := fmt.Sprintf("IPFS mounted at: %s\n", v.IPFS)