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-unixfs
Commits
b7016fd1
Commit
b7016fd1
authored
Sep 13, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix t0090 tar&gz unexpected EOF error
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
a7347318
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
6 deletions
+28
-6
archive/archive.go
archive/archive.go
+23
-4
archive/tar/writer.go
archive/tar/writer.go
+5
-2
No files found.
archive/archive.go
View file @
b7016fd1
...
...
@@ -17,6 +17,18 @@ import (
// TODO: does this need to be configurable?
var
DefaultBufSize
=
1048576
type
identityWriteCloser
struct
{
w
io
.
Writer
}
func
(
i
*
identityWriteCloser
)
Write
(
p
[]
byte
)
(
int
,
error
)
{
return
i
.
w
.
Write
(
p
)
}
func
(
i
*
identityWriteCloser
)
Close
()
error
{
return
nil
}
// DagArchive is equivalent to `ipfs getdag $hash | maybe_tar | maybe_gzip`
func
DagArchive
(
ctx
cxt
.
Context
,
nd
*
mdag
.
Node
,
name
string
,
dag
mdag
.
DAGService
,
archive
bool
,
compression
int
)
(
io
.
Reader
,
error
)
{
...
...
@@ -29,15 +41,16 @@ func DagArchive(ctx cxt.Context, nd *mdag.Node, name string, dag mdag.DAGService
bufw
:=
bufio
.
NewWriterSize
(
pipew
,
DefaultBufSize
)
// compression determines whether to use gzip compression.
var
maybeGzw
io
.
Writer
if
compression
!=
gzip
.
NoCompression
{
var
maybeGzw
io
.
WriteCloser
var
err
error
if
compression
!=
gzip
.
NoCompression
{
maybeGzw
,
err
=
gzip
.
NewWriterLevel
(
bufw
,
compression
)
if
err
!=
nil
{
pipew
.
CloseWithError
(
err
)
return
nil
,
err
}
}
else
{
maybeGzw
=
bufw
maybeGzw
=
&
identityWriteCloser
{
bufw
}
}
if
!
archive
&&
compression
!=
gzip
.
NoCompression
{
...
...
@@ -53,6 +66,11 @@ func DagArchive(ctx cxt.Context, nd *mdag.Node, name string, dag mdag.DAGService
pipew
.
CloseWithError
(
err
)
return
}
maybeGzw
.
Close
()
if
err
:=
bufw
.
Flush
();
err
!=
nil
{
pipew
.
CloseWithError
(
err
)
return
}
pipew
.
Close
()
// everything seems to be ok.
}()
}
else
{
...
...
@@ -70,11 +88,12 @@ func DagArchive(ctx cxt.Context, nd *mdag.Node, name string, dag mdag.DAGService
pipew
.
CloseWithError
(
err
)
return
}
w
.
Close
()
maybeGzw
.
Close
()
if
err
:=
bufw
.
Flush
();
err
!=
nil
{
pipew
.
CloseWithError
(
err
)
return
}
w
.
Close
()
pipew
.
Close
()
// everything seems to be ok.
}()
}
...
...
archive/tar/writer.go
View file @
b7016fd1
...
...
@@ -60,8 +60,11 @@ func (w *Writer) writeFile(nd *mdag.Node, pb *upb.Data, fpath string) error {
}
dagr
:=
uio
.
NewDataFileReader
(
w
.
ctx
,
nd
,
pb
,
w
.
Dag
)
_
,
err
:=
dagr
.
WriteTo
(
w
.
TarW
)
if
_
,
err
:=
dagr
.
WriteTo
(
w
.
TarW
)
;
err
!=
nil
{
return
err
}
w
.
TarW
.
Flush
()
return
nil
}
func
(
w
*
Writer
)
WriteNode
(
nd
*
mdag
.
Node
,
fpath
string
)
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