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
dc66b699
Commit
dc66b699
authored
Oct 03, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix writes zeroing files
parent
47275351
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
fuse/ipns/ipns_unix.go
fuse/ipns/ipns_unix.go
+5
-4
importer/importer_test.go
importer/importer_test.go
+7
-1
No files found.
fuse/ipns/ipns_unix.go
View file @
dc66b699
...
...
@@ -206,7 +206,6 @@ type Node struct {
// For writing
dataBuf
*
bytes
.
Buffer
changed
bool
}
func
(
s
*
Node
)
loadData
()
error
{
...
...
@@ -302,18 +301,18 @@ func (n *Node) Write(req *fuse.WriteRequest, resp *fuse.WriteResponse, intr fs.I
if
req
.
Offset
==
0
{
n
.
dataBuf
.
Reset
()
n
.
dataBuf
.
Write
(
req
.
Data
)
n
.
changed
=
true
resp
.
Size
=
len
(
req
.
Data
)
}
else
{
log
.
Error
(
"Unhandled write to offset!"
)
n
.
dataBuf
=
nil
}
return
nil
}
func
(
n
*
Node
)
Flush
(
req
*
fuse
.
FlushRequest
,
intr
fs
.
Intr
)
fuse
.
Error
{
log
.
Debug
(
"Got flush request
!"
)
log
.
Debug
(
"Got flush request
[%s]!"
,
n
.
name
)
if
n
.
changed
{
if
n
.
dataBuf
!=
nil
{
//TODO:
// This operation holds everything in memory,
// should be changed to stream the block creation/storage
...
...
@@ -351,6 +350,8 @@ func (n *Node) Flush(req *fuse.FlushRequest, intr fs.Intr) fuse.Error {
fmt
.
Println
(
string
(
b
))
//
n
.
dataBuf
=
nil
n
.
wasChanged
()
}
return
nil
...
...
importer/importer_test.go
View file @
dc66b699
...
...
@@ -43,10 +43,16 @@ func TestSizeBasedSplit(t *testing.T) {
testFileConsistency
(
t
,
bs
,
31
*
4095
)
}
func
dup
(
b
[]
byte
)
[]
byte
{
o
:=
make
([]
byte
,
len
(
b
))
copy
(
o
,
b
)
return
o
}
func
testFileConsistency
(
t
*
testing
.
T
,
bs
BlockSplitter
,
nbytes
int
)
{
buf
:=
new
(
bytes
.
Buffer
)
io
.
CopyN
(
buf
,
rand
.
Reader
,
int64
(
nbytes
))
should
:=
buf
.
Bytes
()
should
:=
dup
(
buf
.
Bytes
()
)
nd
,
err
:=
NewDagFromReaderWithSplitter
(
buf
,
bs
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
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