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
370285fc
Commit
370285fc
authored
Mar 10, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove temp code in Coal test, and make Size not have to flush
parent
218cc018
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
28 deletions
+15
-28
unixfs/mod/dagmodifier.go
unixfs/mod/dagmodifier.go
+5
-5
unixfs/mod/dagmodifier_test.go
unixfs/mod/dagmodifier_test.go
+10
-23
No files found.
unixfs/mod/dagmodifier.go
View file @
370285fc
...
...
@@ -137,15 +137,15 @@ func (dm *DagModifier) Write(b []byte) (int, error) {
}
func
(
dm
*
DagModifier
)
Size
()
(
int64
,
error
)
{
// TODO: compute size without flushing, should be easy
err
:=
dm
.
Flush
()
pbn
,
err
:=
ft
.
FromBytes
(
dm
.
curNode
.
Data
)
if
err
!=
nil
{
return
0
,
err
}
pbn
,
err
:=
ft
.
FromBytes
(
dm
.
curNode
.
Data
)
if
err
!=
nil
{
return
0
,
err
if
dm
.
wrBuf
!=
nil
{
if
uint64
(
dm
.
wrBuf
.
Len
())
+
dm
.
writeStart
>
pbn
.
GetFilesize
()
{
return
int64
(
dm
.
wrBuf
.
Len
())
+
int64
(
dm
.
writeStart
),
nil
}
}
return
int64
(
pbn
.
GetFilesize
()),
nil
...
...
unixfs/mod/dagmodifier_test.go
View file @
370285fc
...
...
@@ -177,6 +177,15 @@ func TestMultiWrite(t *testing.T) {
if
n
!=
1
{
t
.
Fatal
(
"Somehow wrote the wrong number of bytes! (n != 1)"
)
}
size
,
err
:=
dagmod
.
Size
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
size
!=
int64
(
i
+
1
)
{
t
.
Fatal
(
"Size was reported incorrectly"
)
}
}
nd
,
err
:=
dagmod
.
GetNode
()
if
err
!=
nil
{
...
...
@@ -305,6 +314,7 @@ func TestMultiWriteCoal(t *testing.T) {
u
.
NewTimeSeededRand
()
.
Read
(
data
)
for
i
:=
0
;
i
<
len
(
data
);
i
++
{
log
.
Error
(
i
)
n
,
err
:=
dagmod
.
WriteAt
(
data
[
:
i
+
1
],
0
)
if
err
!=
nil
{
fmt
.
Println
(
"FAIL AT "
,
i
)
...
...
@@ -314,29 +324,6 @@ func TestMultiWriteCoal(t *testing.T) {
t
.
Fatal
(
"Somehow wrote the wrong number of bytes! (n != 1)"
)
}
// TEMP
nn
,
err
:=
dagmod
.
GetNode
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
r
,
err
:=
uio
.
NewDagReader
(
ctx
,
nn
,
dserv
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
out
,
err
:=
ioutil
.
ReadAll
(
r
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
arrComp
(
out
,
data
[
:
i
+
1
]);
err
!=
nil
{
fmt
.
Println
(
"A "
,
len
(
out
))
fmt
.
Println
(
out
)
fmt
.
Println
(
data
[
:
i
+
1
])
t
.
Fatal
(
err
)
}
//
}
nd
,
err
:=
dagmod
.
GetNode
()
if
err
!=
nil
{
...
...
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