Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
7fb38099
Commit
7fb38099
authored
Jan 21, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop passing errors on content-encoding line
parent
e1222e92
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
17 deletions
+18
-17
cmd/gitlab-zip-cat/main.go
cmd/gitlab-zip-cat/main.go
+4
-6
internal/artifacts/artifact_download.go
internal/artifacts/artifact_download.go
+14
-11
No files found.
cmd/gitlab-zip-cat/main.go
View file @
7fb38099
...
...
@@ -39,15 +39,13 @@ func main() {
archive
,
err
:=
zip
.
OpenReader
(
archiveFileName
)
if
err
!=
nil
{
printError
(
fmt
.
Errorf
(
"open %q: %v"
,
archiveFileName
,
err
))
exitNotFound
()
notFoundError
(
fmt
.
Errorf
(
"open %q: %v"
,
archiveFileName
,
err
))
}
defer
archive
.
Close
()
file
:=
findFileInZip
(
fileName
,
&
archive
.
Reader
)
if
file
==
nil
{
printError
(
fmt
.
Errorf
(
"find %q in %q: not found"
,
fileName
,
archiveFileName
))
exitNotFound
()
notFoundError
(
fmt
.
Errorf
(
"find %q in %q: not found"
,
fileName
,
archiveFileName
))
}
// Start decompressing the file
reader
,
err
:=
file
.
Open
()
...
...
@@ -83,7 +81,7 @@ func fatalError(err error) {
os
.
Exit
(
1
)
}
func
exitNotFound
(
)
{
fmt
.
Printf
(
"%d
\n
"
,
-
zipartifacts
.
StatusEntryNotFound
)
// for the content-length reader
func
notFoundError
(
err
error
)
{
printError
(
err
)
os
.
Exit
(
zipartifacts
.
StatusEntryNotFound
)
}
internal/artifacts/artifact_download.go
View file @
7fb38099
...
...
@@ -17,8 +17,6 @@ import (
"syscall"
)
var
notFoundString
=
fmt
.
Sprintf
(
"%d"
,
-
zipartifacts
.
StatusEntryNotFound
)
func
detectFileContentType
(
fileName
string
)
string
{
contentType
:=
mime
.
TypeByExtension
(
filepath
.
Ext
(
fileName
))
if
contentType
==
""
{
...
...
@@ -50,12 +48,12 @@ func unpackFileFromZip(archiveFileName, encodedFilename string, headers http.Hea
reader
:=
bufio
.
NewReader
(
stdout
)
contentLength
,
err
:=
reader
.
ReadString
(
'\n'
)
if
err
!=
nil
{
if
catFileErr
:=
waitCatFile
(
catFile
);
catFileErr
!=
nil
{
return
catFileErr
}
return
fmt
.
Errorf
(
"read content-length: %v"
,
err
)
}
contentLength
=
strings
.
TrimSuffix
(
contentLength
,
"
\n
"
)
if
contentLength
==
notFoundString
{
return
os
.
ErrNotExist
}
// Write http headers about the file
headers
.
Set
(
"Content-Length"
,
contentLength
)
...
...
@@ -66,15 +64,20 @@ func unpackFileFromZip(archiveFileName, encodedFilename string, headers http.Hea
return
fmt
.
Errorf
(
"copy %v stdout: %v"
,
catFile
.
Args
,
err
)
}
if
err
:=
catFile
.
Wait
();
err
!=
nil
{
if
st
,
ok
:=
helper
.
ExitStatus
(
err
);
ok
&&
st
==
zipartifacts
.
StatusEntryNotFound
{
return
os
.
ErrNotExist
}
return
waitCatFile
(
catFile
)
}
func
waitCatFile
(
cmd
*
exec
.
Cmd
)
error
{
err
:=
cmd
.
Wait
()
if
err
==
nil
{
return
nil
}
return
fmt
.
Errorf
(
"wait for %v to finish: %v"
,
catFile
.
Args
,
err
)
if
st
,
ok
:=
helper
.
ExitStatus
(
err
);
ok
&&
st
==
zipartifacts
.
StatusEntryNotFound
{
return
os
.
ErrNotExist
}
return
fmt
.
Errorf
(
"wait for %v to finish: %v"
,
cmd
.
Args
,
err
)
return
nil
}
// Artifacts downloader doesn't support ranges when downloading a single file
...
...
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