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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
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
Show 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() {
...
@@ -39,15 +39,13 @@ func main() {
archive
,
err
:=
zip
.
OpenReader
(
archiveFileName
)
archive
,
err
:=
zip
.
OpenReader
(
archiveFileName
)
if
err
!=
nil
{
if
err
!=
nil
{
printError
(
fmt
.
Errorf
(
"open %q: %v"
,
archiveFileName
,
err
))
notFoundError
(
fmt
.
Errorf
(
"open %q: %v"
,
archiveFileName
,
err
))
exitNotFound
()
}
}
defer
archive
.
Close
()
defer
archive
.
Close
()
file
:=
findFileInZip
(
fileName
,
&
archive
.
Reader
)
file
:=
findFileInZip
(
fileName
,
&
archive
.
Reader
)
if
file
==
nil
{
if
file
==
nil
{
printError
(
fmt
.
Errorf
(
"find %q in %q: not found"
,
fileName
,
archiveFileName
))
notFoundError
(
fmt
.
Errorf
(
"find %q in %q: not found"
,
fileName
,
archiveFileName
))
exitNotFound
()
}
}
// Start decompressing the file
// Start decompressing the file
reader
,
err
:=
file
.
Open
()
reader
,
err
:=
file
.
Open
()
...
@@ -83,7 +81,7 @@ func fatalError(err error) {
...
@@ -83,7 +81,7 @@ func fatalError(err error) {
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
func
exitNotFound
(
)
{
func
notFoundError
(
err
error
)
{
fmt
.
Printf
(
"%d
\n
"
,
-
zipartifacts
.
StatusEntryNotFound
)
// for the content-length reader
printError
(
err
)
os
.
Exit
(
zipartifacts
.
StatusEntryNotFound
)
os
.
Exit
(
zipartifacts
.
StatusEntryNotFound
)
}
}
internal/artifacts/artifact_download.go
View file @
7fb38099
...
@@ -17,8 +17,6 @@ import (
...
@@ -17,8 +17,6 @@ import (
"syscall"
"syscall"
)
)
var
notFoundString
=
fmt
.
Sprintf
(
"%d"
,
-
zipartifacts
.
StatusEntryNotFound
)
func
detectFileContentType
(
fileName
string
)
string
{
func
detectFileContentType
(
fileName
string
)
string
{
contentType
:=
mime
.
TypeByExtension
(
filepath
.
Ext
(
fileName
))
contentType
:=
mime
.
TypeByExtension
(
filepath
.
Ext
(
fileName
))
if
contentType
==
""
{
if
contentType
==
""
{
...
@@ -50,12 +48,12 @@ func unpackFileFromZip(archiveFileName, encodedFilename string, headers http.Hea
...
@@ -50,12 +48,12 @@ func unpackFileFromZip(archiveFileName, encodedFilename string, headers http.Hea
reader
:=
bufio
.
NewReader
(
stdout
)
reader
:=
bufio
.
NewReader
(
stdout
)
contentLength
,
err
:=
reader
.
ReadString
(
'\n'
)
contentLength
,
err
:=
reader
.
ReadString
(
'\n'
)
if
err
!=
nil
{
if
err
!=
nil
{
if
catFileErr
:=
waitCatFile
(
catFile
);
catFileErr
!=
nil
{
return
catFileErr
}
return
fmt
.
Errorf
(
"read content-length: %v"
,
err
)
return
fmt
.
Errorf
(
"read content-length: %v"
,
err
)
}
}
contentLength
=
strings
.
TrimSuffix
(
contentLength
,
"
\n
"
)
contentLength
=
strings
.
TrimSuffix
(
contentLength
,
"
\n
"
)
if
contentLength
==
notFoundString
{
return
os
.
ErrNotExist
}
// Write http headers about the file
// Write http headers about the file
headers
.
Set
(
"Content-Length"
,
contentLength
)
headers
.
Set
(
"Content-Length"
,
contentLength
)
...
@@ -66,15 +64,20 @@ func unpackFileFromZip(archiveFileName, encodedFilename string, headers http.Hea
...
@@ -66,15 +64,20 @@ func unpackFileFromZip(archiveFileName, encodedFilename string, headers http.Hea
return
fmt
.
Errorf
(
"copy %v stdout: %v"
,
catFile
.
Args
,
err
)
return
fmt
.
Errorf
(
"copy %v stdout: %v"
,
catFile
.
Args
,
err
)
}
}
if
err
:=
catFile
.
Wait
();
err
!=
nil
{
return
waitCatFile
(
catFile
)
if
st
,
ok
:=
helper
.
ExitStatus
(
err
);
ok
&&
st
==
zipartifacts
.
StatusEntryNotFound
{
}
return
os
.
ErrNotExist
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
// 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