add run command

This commit is contained in:
Jeromy 2014-09-10 23:07:01 +00:00 committed by Juan Batiz-Benet
parent b5fd9492d7
commit da1890e5ef
3 changed files with 40 additions and 1 deletions

View File

@ -51,6 +51,7 @@ Use "ipfs help <command>" for more information about a command.
cmdIpfsMount,
cmdIpfsInit,
cmdIpfsServe,
cmdIpfsRun,
},
Flag: *flag.NewFlagSet("ipfs", flag.ExitOnError),
}

34
cmd/ipfs/run.go Normal file
View File

@ -0,0 +1,34 @@
package main
import (
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
"github.com/jbenet/go-ipfs/daemon"
u "github.com/jbenet/go-ipfs/util"
)
var cmdIpfsRun = &commander.Command{
UsageLine: "run",
Short: "run local ifps node.",
Long: `run a local ipfs node with no other interface.
`,
Run: runCmd,
Flag: *flag.NewFlagSet("ipfs-run", flag.ExitOnError),
}
func runCmd(c *commander.Command, inp []string) error {
u.Debug = true
n, err := localNode(true)
if err != nil {
return err
}
dl, err := daemon.NewDaemonListener(n, "localhost:12345")
if err != nil {
return err
}
dl.Listen()
dl.Close()
return nil
}

View File

@ -98,7 +98,11 @@ func (s *Node) Attr() fuse.Attr {
case mdag.PBData_File, mdag.PBData_Raw:
u.DOut("this is a file.\n")
size, _ := s.Nd.Size()
return fuse.Attr{Mode: 0444, Size: uint64(size)}
return fuse.Attr{
Mode: 0444,
Size: uint64(size),
Blocks: uint64(len(s.Nd.Links)),
}
default:
u.PErr("Invalid data type.")
return fuse.Attr{}