Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kubo_final
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anastasiia Chirikova
kubo_final
Commits
23dd82f5
Commit
23dd82f5
authored
9 years ago
by
rht
Browse files
Options
Downloads
Patches
Plain Diff
Fix t0090 tar&gz unexpected EOF error
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
a8dc708b
Branches
Branches containing commit
No related tags found
1 merge request
!1
New
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/sharness/t0090-get.sh
+3
-6
3 additions, 6 deletions
test/sharness/t0090-get.sh
unixfs/archive/archive.go
+23
-4
23 additions, 4 deletions
unixfs/archive/archive.go
unixfs/archive/tar/writer.go
+5
-2
5 additions, 2 deletions
unixfs/archive/tar/writer.go
with
31 additions
and
12 deletions
test/sharness/t0090-get.sh
+
3
−
6
View file @
23dd82f5
...
...
@@ -51,8 +51,7 @@ test_get_cmd() {
test_cmp expected actual
'
# TODO: determine why this fails
test_expect_failure
"ipfs get -a archive output is valid"
'
test_expect_success
"ipfs get -a archive output is valid"
'
tar -xf "$HASH".tar &&
test_cmp "$HASH" data &&
rm "$HASH".tar &&
...
...
@@ -68,8 +67,7 @@ test_get_cmd() {
test_cmp expected actual
'
# TODO(mappum)
test_expect_failure
"gzipped tar archive output is valid"
'
test_expect_success
"gzipped tar archive output is valid"
'
tar -zxf "$HASH".tar.gz &&
test_cmp "$HASH" data &&
rm "$HASH".tar.gz &&
...
...
@@ -105,8 +103,7 @@ test_get_cmd() {
test_cmp expected actual
'
# TODO(mappum)
test_expect_failure
"gzipped tar archive output is valid (directory)"
'
test_expect_success
"gzipped tar archive output is valid (directory)"
'
tar -zxf "$HASH2".tar.gz &&
test_cmp dir/a "$HASH2"/a &&
test_cmp dir/b/c "$HASH2"/b/c &&
...
...
This diff is collapsed.
Click to expand it.
unixfs/archive/archive.go
+
23
−
4
View file @
23dd82f5
...
...
@@ -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.
}()
}
...
...
This diff is collapsed.
Click to expand it.
unixfs/archive/tar/writer.go
+
5
−
2
View file @
23dd82f5
...
...
@@ -60,9 +60,12 @@ 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
{
pb
:=
new
(
upb
.
Data
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment