// updateApply applies an update of the ipfs binary and shuts down the node if successful func updateApply(n *core.IpfsNode) (*UpdateOutput, error) { // TODO: 'force bool' param that stops the daemon (if running) before update output := &UpdateOutput{ OldVersion: updates.Version, } u, err := updates.CheckForUpdate() if err != nil { return nil, err } if u == nil { output.NewVersion = updates.Version return output, nil } output.NewVersion = u.Version if n.OnlineMode() { return nil, errors.New(`You must stop the IPFS daemon before updating.`) } if err = updates.Apply(u); err != nil { return nil, err } return output, nil }
// Mount mounts an IpfsNode instance at a particular path. It // serves until the process receives exit signals (to Unmount). func Mount(ipfs *core.IpfsNode, fpath string, ipfspath string) (mount.Mount, error) { log.Infof("Mounting ipns at %s...", fpath) // setup the Mount abstraction. m := mount.New(ipfs.Context(), fpath) // go serve the mount m.Mount(func(m mount.Mount) error { return internalMount(ipfs, fpath, ipfspath) }, internalUnmount) select { case <-m.Closed(): return nil, fmt.Errorf("failed to mount") case <-time.After(time.Second): // assume it worked... } // bind the mount (ContextCloser) to the node, so that when the node exits // the fsclosers are automatically closed. ipfs.AddCloserChild(m) return m, nil }