@cryptotaxi247 / kubo / commits / 4bcacc593

address most of CR comments

License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>

Jeromy committed Sep 2, 2015 at 10:12 UTC 4bcacc593647bf3cde24e7d0a3147caa89fe87d7
3 files changed +21 -31
commands/files/multipartfile.go
+3 -1
@@ -12,6 +12,8 @@ const (
12 multipartFormdataType = "multipart/form-data"
13 multipartMixedType = "multipart/mixed"
14
15 + applicationSymlink = "application/symlink"
16 +
17 contentTypeHeader = "Content-Type"
18 )
19
@@ -31,7 +33,7 @@ func NewFileFromPart(part *multipart.Part) (File, error) {
33 }
34
35 contentType := part.Header.Get(contentTypeHeader)
34 - if contentType == "symlink" {
36 + if contentType == applicationSymlink {
37 out, err := ioutil.ReadAll(part)
38 if err != nil {
39 return nil, err
commands/http/multifilereader.go
+1 -2
@@ -69,8 +69,7 @@ func (mfr *MultiFileReader) Read(buf []byte) (written int, err error) {
69 if s, ok := file.(*files.Symlink); ok {
70 mfr.currentFile = s
71
72 - // TODO(why): this is a hack. pick a real contentType
73 - contentType = "symlink"
72 + contentType = "application/symlink"
73 } else if file.IsDirectory() {
74 // if file is a directory, create a multifilereader from it
75 // (using 'multipart/mixed')
fuse/readonly/readonly_unix.go
+17 -28
@@ -8,7 +8,6 @@ import (
8 "io"
9 "os"
10 "syscall"
11 - "time"
11
12 fuse "github.com/ipfs/go-ipfs/Godeps/_workspace/src/bazil.org/fuse"
13 fs "github.com/ipfs/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs"
@@ -60,8 +59,6 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
59 return nil, fuse.ENOENT
60 }
61
63 - log.Error("RESOLVE: ", name)
64 - ctx, _ = context.WithTimeout(ctx, time.Second/2)
62 nd, err := s.Ipfs.Resolver.ResolvePath(ctx, path.Path(name))
63 if err != nil {
64 // todo: make this error more versatile.
@@ -100,35 +97,27 @@ func (s *Node) Attr(ctx context.Context, a *fuse.Attr) error {
97 }
98 switch s.cached.GetType() {
99 case ftpb.Data_Directory:
103 - *a = fuse.Attr{
104 - Mode: os.ModeDir | 0555,
105 - Uid: uint32(os.Getuid()),
106 - Gid: uint32(os.Getgid()),
107 - }
100 + a.Mode = os.ModeDir | 0555
101 + a.Uid = uint32(os.Getuid())
102 + a.Gid = uint32(os.Getgid())
103 case ftpb.Data_File:
104 size := s.cached.GetFilesize()
110 - *a = fuse.Attr{
111 - Mode: 0444,
112 - Size: uint64(size),
113 - Blocks: uint64(len(s.Nd.Links)),
114 - Uid: uint32(os.Getuid()),
115 - Gid: uint32(os.Getgid()),
116 - }
105 + a.Mode = 0444
106 + a.Size = uint64(size)
107 + a.Blocks = uint64(len(s.Nd.Links))
108 + a.Uid = uint32(os.Getuid())
109 + a.Gid = uint32(os.Getgid())
110 case ftpb.Data_Raw:
118 - *a = fuse.Attr{
119 - Mode: 0444,
120 - Size: uint64(len(s.cached.GetData())),
121 - Blocks: uint64(len(s.Nd.Links)),
122 - Uid: uint32(os.Getuid()),
123 - Gid: uint32(os.Getgid()),
124 - }
111 + a.Mode = 0444
112 + a.Size = uint64(len(s.cached.GetData()))
113 + a.Blocks = uint64(len(s.Nd.Links))
114 + a.Uid = uint32(os.Getuid())
115 + a.Gid = uint32(os.Getgid())
116 case ftpb.Data_Symlink:
126 - *a = fuse.Attr{
127 - Mode: 0777 | os.ModeSymlink,
128 - Size: uint64(len(s.cached.GetData())),
129 - Uid: uint32(os.Getuid()),
130 - Gid: uint32(os.Getgid()),
131 - }
117 + a.Mode = 0777 | os.ModeSymlink
118 + a.Size = uint64(len(s.cached.GetData()))
119 + a.Uid = uint32(os.Getuid())
120 + a.Gid = uint32(os.Getgid())
121
122 default:
123 return fmt.Errorf("Invalid data type - %s", s.cached.GetType())