Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
b5fd9492
Commit
b5fd9492
authored
10 years ago
by
Jeromy
Committed by
Juan Batiz-Benet
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes to make interface more usable
parent
235a7674
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
9 deletions
+46
-9
core/commands/add.go
core/commands/add.go
+10
-0
core/commands/commands.go
core/commands/commands.go
+4
-0
core/core.go
core/core.go
+1
-0
fuse/readonly/readonly_unix.go
fuse/readonly/readonly_unix.go
+24
-7
merkledag/merkledag.go
merkledag/merkledag.go
+6
-2
routing/dht/routing.go
routing/dht/routing.go
+1
-0
No files found.
core/commands/add.go
View file @
b5fd9492
...
...
@@ -103,6 +103,16 @@ func addFile(n *core.IpfsNode, fpath string, depth int) (*dag.Node, error) {
return
nil
,
err
}
k
,
err
:=
root
.
Key
()
if
err
!=
nil
{
return
nil
,
err
}
log
.
Info
(
"Adding file: %s = %s
\n
"
,
fpath
,
k
.
Pretty
())
for
_
,
l
:=
range
root
.
Links
{
log
.
Info
(
"SubBlock: %s
\n
"
,
l
.
Hash
.
B58String
())
}
return
root
,
addNode
(
n
,
root
,
fpath
)
}
...
...
This diff is collapsed.
Click to expand it.
core/commands/commands.go
View file @
b5fd9492
...
...
@@ -4,6 +4,10 @@ import (
"io"
"github.com/jbenet/go-ipfs/core"
logging
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
)
var
log
=
logging
.
MustGetLogger
(
"commands"
)
type
CmdFunc
func
(
*
core
.
IpfsNode
,
[]
string
,
map
[
string
]
interface
{},
io
.
Writer
)
error
This diff is collapsed.
Click to expand it.
core/core.go
View file @
b5fd9492
...
...
@@ -16,6 +16,7 @@ import (
exchange
"github.com/jbenet/go-ipfs/exchange"
bitswap
"github.com/jbenet/go-ipfs/exchange/bitswap"
merkledag
"github.com/jbenet/go-ipfs/merkledag"
namesys
"github.com/jbenet/go-ipfs/namesys"
inet
"github.com/jbenet/go-ipfs/net"
mux
"github.com/jbenet/go-ipfs/net/mux"
netservice
"github.com/jbenet/go-ipfs/net/service"
...
...
This diff is collapsed.
Click to expand it.
fuse/readonly/readonly_unix.go
View file @
b5fd9492
...
...
@@ -14,6 +14,8 @@ import (
"syscall"
"time"
"code.google.com/p/goprotobuf/proto"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs"
core
"github.com/jbenet/go-ipfs/core"
...
...
@@ -72,20 +74,35 @@ func (*Root) ReadDir(intr fs.Intr) ([]fuse.Dirent, fuse.Error) {
// Node is the core object representing a filesystem tree node.
type
Node
struct
{
Ipfs
*
core
.
IpfsNode
Nd
*
mdag
.
Node
fd
*
mdag
.
DagReader
Ipfs
*
core
.
IpfsNode
Nd
*
mdag
.
Node
fd
*
mdag
.
DagReader
cached
*
mdag
.
PBData
}
func
(
s
*
Node
)
loadData
()
error
{
s
.
cached
=
new
(
mdag
.
PBData
)
return
proto
.
Unmarshal
(
s
.
Nd
.
Data
,
s
.
cached
)
}
// Attr returns the attributes of a given node.
func
(
s
*
Node
)
Attr
()
fuse
.
Attr
{
u
.
DOut
(
"Node attr.
\n
"
)
if
len
(
s
.
Nd
.
Links
)
>
0
{
if
s
.
cached
==
nil
{
s
.
loadData
()
}
switch
s
.
cached
.
GetType
()
{
case
mdag
.
PBData_Directory
:
u
.
DOut
(
"this is a directory.
\n
"
)
return
fuse
.
Attr
{
Mode
:
os
.
ModeDir
|
0555
}
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
)}
default
:
u
.
PErr
(
"Invalid data type."
)
return
fuse
.
Attr
{}
}
size
,
_
:=
s
.
Nd
.
Size
()
return
fuse
.
Attr
{
Mode
:
0444
,
Size
:
uint64
(
size
)}
}
// Lookup performs a lookup under this node.
...
...
This diff is collapsed.
Click to expand it.
merkledag/merkledag.go
View file @
b5fd9492
...
...
@@ -3,7 +3,8 @@ package merkledag
import
(
"fmt"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
proto
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
logging
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
blocks
"github.com/jbenet/go-ipfs/blocks"
...
...
@@ -11,6 +12,8 @@ import (
u
"github.com/jbenet/go-ipfs/util"
)
var
log
=
logging
.
MustGetLogger
(
"commands"
)
// NodeMap maps u.Keys to Nodes.
// We cannot use []byte/Multihash for keys :(
// so have to convert Multihash bytes to string (u.Key)
...
...
@@ -105,7 +108,7 @@ type DAGService struct {
// Add adds a node to the DAGService, storing the block in the BlockService
func
(
n
*
DAGService
)
Add
(
nd
*
Node
)
(
u
.
Key
,
error
)
{
k
,
_
:=
nd
.
Key
()
u
.
DOut
(
"DagService Add [%s]
\n
"
,
k
.
Pretty
())
log
.
Debug
(
"DagService Add [%s]
\n
"
,
k
.
Pretty
())
if
n
==
nil
{
return
""
,
fmt
.
Errorf
(
"DAGService is nil"
)
}
...
...
@@ -126,6 +129,7 @@ func (n *DAGService) Add(nd *Node) (u.Key, error) {
func
(
n
*
DAGService
)
AddRecursive
(
nd
*
Node
)
error
{
_
,
err
:=
n
.
Add
(
nd
)
if
err
!=
nil
{
log
.
Info
(
"AddRecursive Error: %s
\n
"
,
err
)
return
err
}
...
...
This diff is collapsed.
Click to expand it.
routing/dht/routing.go
View file @
b5fd9492
...
...
@@ -101,6 +101,7 @@ func (dht *IpfsDHT) Provide(ctx context.Context, key u.Key) error {
dht
.
providers
.
AddProvider
(
key
,
dht
.
self
)
peers
:=
dht
.
routingTables
[
0
]
.
NearestPeers
(
kb
.
ConvertKey
(
key
),
PoolSize
)
if
len
(
peers
)
==
0
{
// Early out for no targets
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment