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-dms3
Commits
727bf49e
Unverified
Commit
727bf49e
authored
Sep 26, 2018
by
Steven Allen
Committed by
GitHub
Sep 26, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5525 from overbool/fix/issue-#5055
fix(unixfs): issue #5055
parents
1e0d53fe
5d173bf3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
32 deletions
+32
-32
core/commands/ls.go
core/commands/ls.go
+2
-2
core/commands/unixfs/ls.go
core/commands/unixfs/ls.go
+5
-6
fuse/readonly/readonly_unix.go
fuse/readonly/readonly_unix.go
+25
-24
No files found.
core/commands/ls.go
View file @
727bf49e
...
...
@@ -138,7 +138,7 @@ The JSON output contains type information.
switch
link
.
Cid
.
Type
()
{
case
cid
.
Raw
:
// No need to check with raw leaves
t
=
unixfs
pb
.
Data_
File
t
=
unixfs
.
T
File
case
cid
.
DagProtobuf
:
linkNode
,
err
:=
link
.
GetNode
(
req
.
Context
(),
dserv
)
if
err
==
ipld
.
ErrNotFound
&&
!
resolve
{
...
...
@@ -193,7 +193,7 @@ The JSON output contains type information.
fmt
.
Fprintln
(
w
,
"Hash
\t
Size
\t
Name"
)
}
for
_
,
link
:=
range
object
.
Links
{
if
link
.
Type
==
unixfs
pb
.
Data_
Directory
{
if
link
.
Type
==
unixfs
.
T
Directory
{
link
.
Name
+=
"/"
}
fmt
.
Fprintf
(
w
,
"%s
\t
%v
\t
%s
\n
"
,
link
.
Hash
,
link
.
Size
,
link
.
Name
)
...
...
core/commands/unixfs/ls.go
View file @
727bf49e
...
...
@@ -14,7 +14,6 @@ import (
e
"github.com/ipfs/go-ipfs/core/commands/e"
unixfs
"gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs"
uio
"gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs/io"
unixfspb
"gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs/pb"
merkledag
"gx/ipfs/QmcBoNcAP6qDjgRBew7yjvCqHq7p5jMstE44jPUBWBxzsV/go-merkledag"
path
"gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path"
resolver
"gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path/resolver"
...
...
@@ -135,13 +134,13 @@ possible, please use 'ipfs ls' instead.
}
switch
t
{
case
unixfs
pb
.
Data_
File
:
case
unixfs
.
T
File
:
break
case
unixfs
pb
.
Data_
HAMTShard
:
case
unixfs
.
T
HAMTShard
:
// We need a streaming ls API for this.
res
.
SetError
(
fmt
.
Errorf
(
"cannot list large directories yet"
),
cmdkit
.
ErrNormal
)
return
case
unixfs
pb
.
Data_
Directory
:
case
unixfs
.
T
Directory
:
links
:=
make
([]
LsLink
,
len
(
merkleNode
.
Links
()))
output
.
Objects
[
hash
]
.
Links
=
links
for
i
,
link
:=
range
merkleNode
.
Links
()
{
...
...
@@ -167,14 +166,14 @@ possible, please use 'ipfs ls' instead.
Hash
:
link
.
Cid
.
String
(),
Type
:
t
.
String
(),
}
if
t
==
unixfs
pb
.
Data_
File
{
if
t
==
unixfs
.
T
File
{
lsLink
.
Size
=
d
.
FileSize
()
}
else
{
lsLink
.
Size
=
link
.
Size
}
links
[
i
]
=
lsLink
}
case
unixfs
pb
.
Data_
Symlink
:
case
unixfs
.
T
Symlink
:
res
.
SetError
(
fmt
.
Errorf
(
"cannot list symlinks yet"
),
cmdkit
.
ErrNormal
)
return
default
:
...
...
fuse/readonly/readonly_unix.go
View file @
727bf49e
...
...
@@ -11,8 +11,8 @@ import (
"syscall"
core
"github.com/ipfs/go-ipfs/core"
ft
"gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs"
uio
"gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs/io"
ftpb
"gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs/pb"
mdag
"gx/ipfs/QmcBoNcAP6qDjgRBew7yjvCqHq7p5jMstE44jPUBWBxzsV/go-merkledag"
path
"gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path"
...
...
@@ -21,7 +21,6 @@ import (
fs
"gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse/fs"
logging
"gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log"
ipld
"gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
proto
"gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto"
)
var
log
=
logging
.
Logger
(
"fuse/ipfs"
)
...
...
@@ -93,13 +92,16 @@ func (*Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
type
Node
struct
{
Ipfs
*
core
.
IpfsNode
Nd
ipld
.
Node
cached
*
ft
pb
.
Data
cached
*
ft
.
FSNode
}
func
(
s
*
Node
)
loadData
()
error
{
if
pbnd
,
ok
:=
s
.
Nd
.
(
*
mdag
.
ProtoNode
);
ok
{
s
.
cached
=
new
(
ftpb
.
Data
)
return
proto
.
Unmarshal
(
pbnd
.
Data
(),
s
.
cached
)
fsn
,
err
:=
ft
.
FSNodeFromBytes
(
pbnd
.
Data
())
if
err
!=
nil
{
return
err
}
s
.
cached
=
fsn
}
return
nil
}
...
...
@@ -119,23 +121,23 @@ func (s *Node) Attr(ctx context.Context, a *fuse.Attr) error {
return
fmt
.
Errorf
(
"readonly: loadData() failed: %s"
,
err
)
}
}
switch
s
.
cached
.
Get
Type
()
{
case
ft
pb
.
Data_
Directory
,
ft
pb
.
Data_
HAMTShard
:
switch
s
.
cached
.
Type
()
{
case
ft
.
T
Directory
,
ft
.
T
HAMTShard
:
a
.
Mode
=
os
.
ModeDir
|
0555
case
ft
pb
.
Data_
File
:
size
:=
s
.
cached
.
Get
File
s
ize
()
case
ft
.
T
File
:
size
:=
s
.
cached
.
File
S
ize
()
a
.
Mode
=
0444
a
.
Size
=
uint64
(
size
)
a
.
Blocks
=
uint64
(
len
(
s
.
Nd
.
Links
()))
case
ft
pb
.
Data_
Raw
:
case
ft
.
T
Raw
:
a
.
Mode
=
0444
a
.
Size
=
uint64
(
len
(
s
.
cached
.
Get
Data
()))
a
.
Size
=
uint64
(
len
(
s
.
cached
.
Data
()))
a
.
Blocks
=
uint64
(
len
(
s
.
Nd
.
Links
()))
case
ft
pb
.
Data_
Symlink
:
case
ft
.
T
Symlink
:
a
.
Mode
=
0777
|
os
.
ModeSymlink
a
.
Size
=
uint64
(
len
(
s
.
cached
.
Get
Data
()))
a
.
Size
=
uint64
(
len
(
s
.
cached
.
Data
()))
default
:
return
fmt
.
Errorf
(
"invalid data type - %s"
,
s
.
cached
.
Get
Type
())
return
fmt
.
Errorf
(
"invalid data type - %s"
,
s
.
cached
.
Type
())
}
return
nil
}
...
...
@@ -192,21 +194,20 @@ func (s *Node) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
case
*
mdag
.
RawNode
:
t
=
fuse
.
DT_File
case
*
mdag
.
ProtoNode
:
var
data
ftpb
.
Data
if
err
:=
proto
.
Unmarshal
(
nd
.
Data
(),
&
data
);
err
!=
nil
{
if
fsn
,
err
:=
ft
.
FSNodeFromBytes
(
nd
.
Data
());
err
!=
nil
{
log
.
Warning
(
"failed to unmarshal protonode data field:"
,
err
)
}
else
{
switch
data
.
Get
Type
()
{
case
ft
pb
.
Data_
Directory
,
ft
pb
.
Data_
HAMTShard
:
switch
fsn
.
Type
()
{
case
ft
.
T
Directory
,
ft
.
T
HAMTShard
:
t
=
fuse
.
DT_Dir
case
ft
pb
.
Data_File
,
ftpb
.
Data_
Raw
:
case
ft
.
TFile
,
ft
.
T
Raw
:
t
=
fuse
.
DT_File
case
ft
pb
.
Data_
Symlink
:
case
ft
.
T
Symlink
:
t
=
fuse
.
DT_Link
case
ft
pb
.
Data_
Metadata
:
case
ft
.
T
Metadata
:
log
.
Error
(
"metadata object in fuse should contain its wrapped type"
)
default
:
log
.
Error
(
"unrecognized protonode data type: "
,
data
.
Get
Type
())
log
.
Error
(
"unrecognized protonode data type: "
,
fsn
.
Type
())
}
}
}
...
...
@@ -230,10 +231,10 @@ func (s *Node) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fu
}
func
(
s
*
Node
)
Readlink
(
ctx
context
.
Context
,
req
*
fuse
.
ReadlinkRequest
)
(
string
,
error
)
{
if
s
.
cached
==
nil
||
s
.
cached
.
Get
Type
()
!=
ft
pb
.
Data_
Symlink
{
if
s
.
cached
==
nil
||
s
.
cached
.
Type
()
!=
ft
.
T
Symlink
{
return
""
,
fuse
.
Errno
(
syscall
.
EINVAL
)
}
return
string
(
s
.
cached
.
Get
Data
()),
nil
return
string
(
s
.
cached
.
Data
()),
nil
}
func
(
s
*
Node
)
Read
(
ctx
context
.
Context
,
req
*
fuse
.
ReadRequest
,
resp
*
fuse
.
ReadResponse
)
error
{
...
...
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