Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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-ce
Commits
085e5087
Commit
085e5087
authored
Jan 19, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fixed and improvements for build artifacts implementation
parent
5ae1356e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
16 deletions
+19
-16
internal/artifacts/artifact_download.go
internal/artifacts/artifact_download.go
+2
-1
internal/artifacts/artifact_download_test.go
internal/artifacts/artifact_download_test.go
+9
-2
internal/artifacts/artifacts_upload.go
internal/artifacts/artifacts_upload.go
+3
-2
internal/artifacts/artifacts_upload_test.go
internal/artifacts/artifacts_upload_test.go
+1
-1
internal/upload/uploads.go
internal/upload/uploads.go
+4
-10
No files found.
internal/artifacts/artifact_download.go
View file @
085e5087
...
...
@@ -6,6 +6,7 @@ import (
"archive/zip"
"encoding/base64"
"errors"
"fmt"
"io"
"mime"
"net/http"
...
...
@@ -89,7 +90,7 @@ func DownloadArtifact(myAPI *api.API) http.Handler {
http
.
NotFound
(
w
,
r
)
return
}
else
if
err
!=
nil
{
helper
.
Fail500
(
w
,
err
)
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"DownloadArtifact: %v"
,
err
)
)
}
},
""
)
}
internal/artifacts/artifact_download_test.go
View file @
085e5087
...
...
@@ -29,7 +29,7 @@ func testArtifactDownloadServer(t *testing.T, archive string, entry string) *htt
Entry
:
base64
.
StdEncoding
.
EncodeToString
([]
byte
(
entry
)),
})
if
err
!=
nil
{
t
.
Fatal
(
"Expected to marshal"
)
t
.
Fatal
(
err
)
}
w
.
Write
(
data
)
})
...
...
@@ -69,7 +69,14 @@ func TestDownloadingFromValidArchive(t *testing.T) {
response
:=
testDownloadArtifact
(
t
,
ts
)
testhelper
.
AssertResponseCode
(
t
,
response
,
200
)
testhelper
.
AssertResponseHeader
(
t
,
response
,
"Content-Type"
,
"text/plain; charset=utf-8"
)
testhelper
.
AssertResponseHeader
(
t
,
response
,
"Content-Type"
,
"text/plain; charset=utf-8"
)
testhelper
.
AssertResponseHeader
(
t
,
response
,
"Content-Disposition"
,
"attachment; filename=
\"
test.txt
\"
"
)
testhelper
.
AssertResponseBody
(
t
,
response
,
"testtest"
)
}
...
...
internal/artifacts/artifacts_upload.go
View file @
085e5087
...
...
@@ -12,18 +12,19 @@ import (
"os"
)
// The artifactsFormFilter allows to pass only the `file` as file in body
type
artifactsUploadProcessor
struct
{
TempPath
string
metadataFile
string
}
func
(
a
*
artifactsUploadProcessor
)
ProcessFile
(
formName
,
fileName
string
,
writer
*
multipart
.
Writer
)
error
{
// ProcessFile for artifacts requires file form-data field name to eq `file`
if
formName
!=
"file"
{
return
fmt
.
Errorf
(
"Invalid form field: %q"
,
formName
)
}
if
a
.
metadataFile
!=
""
{
return
fmt
.
Errorf
(
"
Multiple files
"
)
return
fmt
.
Errorf
(
"
Artifacts request contains more than one file!
"
)
}
// Create temporary file for metadata and store it's path
...
...
internal/artifacts/artifacts_upload_test.go
View file @
085e5087
...
...
@@ -71,7 +71,7 @@ func testArtifactsUploadServer(t *testing.T, tempPath string) *httptest.Server {
w
.
WriteHeader
(
404
)
return
}
if
!
bytes
.
Contains
(
metadata
,
[]
byte
(
metadataHeader
))
{
if
!
bytes
.
HasPrefix
(
metadata
[
4
:
]
,
[]
byte
(
metadataHeader
))
{
w
.
WriteHeader
(
400
)
return
}
...
...
internal/upload/uploads.go
View file @
085e5087
...
...
@@ -75,11 +75,8 @@ func rewriteFormFilesFromMultipart(r *http.Request, writer *multipart.Writer, te
file
.
Close
()
if
filter
!=
nil
{
err
=
filter
.
ProcessFile
(
name
,
file
.
Name
(),
writer
)
if
err
!=
nil
{
return
cleanup
,
err
}
if
err
:=
filter
.
ProcessFile
(
name
,
file
.
Name
(),
writer
);
err
!=
nil
{
return
cleanup
,
err
}
}
else
{
np
,
err
:=
writer
.
CreatePart
(
p
.
Header
)
...
...
@@ -92,11 +89,8 @@ func rewriteFormFilesFromMultipart(r *http.Request, writer *multipart.Writer, te
return
cleanup
,
err
}
if
filter
!=
nil
{
err
=
filter
.
ProcessField
(
name
,
writer
)
if
err
!=
nil
{
return
cleanup
,
err
}
if
err
:=
filter
.
ProcessField
(
name
,
writer
);
err
!=
nil
{
return
cleanup
,
err
}
}
}
...
...
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