Commit 350b8333 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

Merge pull request #277 from jbenet/fuse-fix

Fix buffer size bug in fuse mounts
parents 3155fa2c 387d0a93
......@@ -5,7 +5,6 @@ import (
"crypto/rand"
"io/ioutil"
"os"
"runtime"
"strings"
"testing"
"time"
......@@ -300,10 +299,6 @@ func TestFastRepublish(t *testing.T) {
// Test writing a medium sized file one byte at a time
func TestMultiWrite(t *testing.T) {
if runtime.GOOS == "darwin" {
link := "https://github.com/jbenet/go-ipfs/issues/147"
t.Skipf("Skipping as is broken in OSX. See %s", link)
}
_, mnt := setupIpnsTest(t, nil)
defer mnt.Close()
......
......@@ -232,6 +232,9 @@ func (s *Node) Attr() fuse.Attr {
log.Errorf("Error getting size of file: %s", err)
size = 0
}
if size == 0 {
size = s.dagMod.Size()
}
return fuse.Attr{
Mode: 0666,
Size: size,
......
......@@ -98,13 +98,20 @@ func (s *Node) Attr() fuse.Attr {
switch s.cached.GetType() {
case ftpb.Data_Directory:
return fuse.Attr{Mode: os.ModeDir | 0555}
case ftpb.Data_File, ftpb.Data_Raw:
size, _ := s.Nd.Size()
case ftpb.Data_File:
size := s.cached.GetFilesize()
return fuse.Attr{
Mode: 0444,
Size: uint64(size),
Blocks: uint64(len(s.Nd.Links)),
}
case ftpb.Data_Raw:
return fuse.Attr{
Mode: 0444,
Size: uint64(len(s.cached.GetData())),
Blocks: uint64(len(s.Nd.Links)),
}
default:
log.Error("Invalid data type.")
return fuse.Attr{}
......
......@@ -48,7 +48,7 @@ test_expect_success "generate 100MB file using go-random" '
test_expect_success "sha1 of the file looks ok" '
echo "54dc0dbbc353b2ffb745285793f89af0c9d98449 mountdir/bigfile" >sha1_expected &&
sha1sum mountdir/bigfile >sha1_actual &&
shasum mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'
......@@ -63,7 +63,7 @@ test_expect_success "ipfs add bigfile output looks good" '
'
test_expect_success "ipfs cat succeeds" '
ipfs cat $HASH | sha1sum >sha1_actual
ipfs cat $HASH | shasum >sha1_actual
'
test_expect_success "ipfs cat output looks good" '
......@@ -72,7 +72,7 @@ test_expect_success "ipfs cat output looks good" '
'
test_expect_success "cat ipfs/bigfile succeeds" '
cat ipfs/$HASH | sha1sum >sha1_actual
cat ipfs/$HASH | shasum >sha1_actual
'
test_expect_success "cat ipfs/bigfile looks good" '
......
......@@ -173,6 +173,13 @@ func (dm *DagModifier) WriteAt(b []byte, offset uint64) (int, error) {
return origlen, nil
}
func (dm *DagModifier) Size() uint64 {
if dm == nil {
return 0
}
return dm.pbdata.GetFilesize()
}
// splitBytes uses a splitterFunc to turn a large array of bytes
// into many smaller arrays of bytes
func splitBytes(b []byte, spl chunk.BlockSplitter) [][]byte {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment