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
e1222e92
Commit
e1222e92
authored
Jan 21, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass zip entry name as Base64
parent
9713dc07
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
19 deletions
+27
-19
cmd/gitlab-zip-cat/main.go
cmd/gitlab-zip-cat/main.go
+6
-1
internal/artifacts/artifact_download.go
internal/artifacts/artifact_download.go
+8
-18
internal/zipartifacts/entry.go
internal/zipartifacts/entry.go
+13
-0
No files found.
cmd/gitlab-zip-cat/main.go
View file @
e1222e92
...
...
@@ -31,7 +31,12 @@ func main() {
}
archiveFileName
:=
os
.
Args
[
1
]
fileName
:=
os
.
Args
[
2
]
fileName
,
err
:=
zipartifacts
.
DecodeFileEntry
(
os
.
Args
[
2
])
if
err
!=
nil
{
fatalError
(
fmt
.
Errorf
(
"decode entry %q: %v"
,
os
.
Args
[
2
],
err
))
}
archive
,
err
:=
zip
.
OpenReader
(
archiveFileName
)
if
err
!=
nil
{
printError
(
fmt
.
Errorf
(
"open %q: %v"
,
archiveFileName
,
err
))
...
...
internal/artifacts/artifact_download.go
View file @
e1222e92
...
...
@@ -5,7 +5,6 @@ import (
"../helper"
"../zipartifacts"
"bufio"
"encoding/base64"
"errors"
"fmt"
"io"
...
...
@@ -20,14 +19,6 @@ import (
var
notFoundString
=
fmt
.
Sprintf
(
"%d"
,
-
zipartifacts
.
StatusEntryNotFound
)
func
decodeFileEntry
(
entry
string
)
(
string
,
error
)
{
decoded
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
entry
)
if
err
!=
nil
{
return
""
,
err
}
return
string
(
decoded
),
nil
}
func
detectFileContentType
(
fileName
string
)
string
{
contentType
:=
mime
.
TypeByExtension
(
filepath
.
Ext
(
fileName
))
if
contentType
==
""
{
...
...
@@ -36,8 +27,13 @@ func detectFileContentType(fileName string) string {
return
contentType
}
func
unpackFileFromZip
(
archiveFileName
,
fileName
string
,
headers
http
.
Header
,
output
io
.
Writer
)
error
{
catFile
:=
exec
.
Command
(
"gitlab-zip-cat"
,
archiveFileName
,
fileName
)
func
unpackFileFromZip
(
archiveFileName
,
encodedFilename
string
,
headers
http
.
Header
,
output
io
.
Writer
)
error
{
fileName
,
err
:=
zipartifacts
.
DecodeFileEntry
(
encodedFilename
)
if
err
!=
nil
{
return
err
}
catFile
:=
exec
.
Command
(
"gitlab-zip-cat"
,
archiveFileName
,
encodedFilename
)
catFile
.
Stderr
=
os
.
Stderr
catFile
.
SysProcAttr
=
&
syscall
.
SysProcAttr
{
Setpgid
:
true
}
stdout
,
err
:=
catFile
.
StdoutPipe
()
...
...
@@ -89,13 +85,7 @@ func DownloadArtifact(myAPI *api.API) http.Handler {
return
}
fileName
,
err
:=
decodeFileEntry
(
a
.
Entry
)
if
err
!=
nil
{
helper
.
Fail500
(
w
,
err
)
return
}
err
=
unpackFileFromZip
(
a
.
Archive
,
fileName
,
w
.
Header
(),
w
)
err
:=
unpackFileFromZip
(
a
.
Archive
,
a
.
Entry
,
w
.
Header
(),
w
)
if
os
.
IsNotExist
(
err
)
{
http
.
NotFound
(
w
,
r
)
return
...
...
internal/zipartifacts/entry.go
0 → 100644
View file @
e1222e92
package
zipartifacts
import
(
"encoding/base64"
)
func
DecodeFileEntry
(
entry
string
)
(
string
,
error
)
{
decoded
,
err
:=
base64
.
StdEncoding
.
DecodeString
(
entry
)
if
err
!=
nil
{
return
""
,
err
}
return
string
(
decoded
),
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