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
41510837
Commit
41510837
authored
Mar 25, 2019
by
Jacob Vosmaer
Committed by
Nick Thomas
Mar 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shorten error messages to D&K style
parent
545a9b6e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
internal/objectstore/multipart.go
internal/objectstore/multipart.go
+9
-9
internal/sendfile/sendfile.go
internal/sendfile/sendfile.go
+1
-1
No files found.
internal/objectstore/multipart.go
View file @
41510837
...
...
@@ -76,7 +76,7 @@ func NewMultipart(ctx context.Context, partURLs []string, completeURL, abortURL,
n
,
err
:=
io
.
Copy
(
ioutil
.
Discard
,
pr
)
if
err
!=
nil
{
m
.
uploadError
=
fmt
.
Errorf
(
"
cannot
drain pipe: %v"
,
err
)
m
.
uploadError
=
fmt
.
Errorf
(
"drain pipe: %v"
,
err
)
return
}
if
n
>
0
{
...
...
@@ -120,12 +120,12 @@ func (m *Multipart) cleanup(ctx context.Context) {
func
(
m
*
Multipart
)
complete
(
cmu
*
CompleteMultipartUpload
)
error
{
body
,
err
:=
xml
.
Marshal
(
cmu
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"
cannot
marshal CompleteMultipartUpload request: %v"
,
err
)
return
fmt
.
Errorf
(
"marshal CompleteMultipartUpload request: %v"
,
err
)
}
req
,
err
:=
http
.
NewRequest
(
"POST"
,
m
.
CompleteURL
,
bytes
.
NewReader
(
body
))
if
err
!=
nil
{
return
fmt
.
Errorf
(
"c
annot c
reate CompleteMultipartUpload request: %v"
,
err
)
return
fmt
.
Errorf
(
"create CompleteMultipartUpload request: %v"
,
err
)
}
req
.
ContentLength
=
int64
(
len
(
body
))
req
.
Header
.
Set
(
"Content-Type"
,
"application/xml"
)
...
...
@@ -144,7 +144,7 @@ func (m *Multipart) complete(cmu *CompleteMultipartUpload) error {
result
:=
&
compoundCompleteMultipartUploadResult
{}
decoder
:=
xml
.
NewDecoder
(
resp
.
Body
)
if
err
:=
decoder
.
Decode
(
&
result
);
err
!=
nil
{
return
fmt
.
Errorf
(
"
cannot
decode CompleteMultipartUpload answer: %v"
,
err
)
return
fmt
.
Errorf
(
"decode CompleteMultipartUpload answer: %v"
,
err
)
}
if
result
.
isError
()
{
...
...
@@ -152,7 +152,7 @@ func (m *Multipart) complete(cmu *CompleteMultipartUpload) error {
}
if
result
.
CompleteMultipartUploadResult
==
nil
{
return
fmt
.
Errorf
(
"
cannot read CompleteMultipartUpload answer
"
)
return
fmt
.
Errorf
(
"
empty CompleteMultipartUploadResult
"
)
}
m
.
extractETag
(
result
.
ETag
)
...
...
@@ -178,7 +178,7 @@ func (m *Multipart) verifyETag(cmu *CompleteMultipartUpload) error {
func
(
m
*
Multipart
)
readAndUploadOnePart
(
partURL
string
,
putHeaders
map
[
string
]
string
,
src
io
.
Reader
,
partNumber
int
)
(
*
completeMultipartUploadPart
,
error
)
{
file
,
err
:=
ioutil
.
TempFile
(
""
,
"part-buffer"
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"
unable to create a temporary file for buffering
: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"
create temporary buffer file
: %v"
,
err
)
}
defer
func
(
path
string
)
{
if
err
:=
os
.
Remove
(
path
);
err
!=
nil
{
...
...
@@ -188,19 +188,19 @@ func (m *Multipart) readAndUploadOnePart(partURL string, putHeaders map[string]s
n
,
err
:=
io
.
Copy
(
file
,
src
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"
cannot
write part %d to disk: %v"
,
partNumber
,
err
)
return
nil
,
fmt
.
Errorf
(
"write part %d to disk: %v"
,
partNumber
,
err
)
}
if
n
==
0
{
return
nil
,
nil
}
if
_
,
err
=
file
.
Seek
(
0
,
io
.
SeekStart
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"
cannot
rewind part %d temporary dump : %v"
,
partNumber
,
err
)
return
nil
,
fmt
.
Errorf
(
"rewind part %d temporary dump : %v"
,
partNumber
,
err
)
}
etag
,
err
:=
m
.
uploadPart
(
partURL
,
putHeaders
,
file
,
n
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"
cannot
upload part %d: %v"
,
partNumber
,
err
)
return
nil
,
fmt
.
Errorf
(
"upload part %d: %v"
,
partNumber
,
err
)
}
return
&
completeMultipartUploadPart
{
PartNumber
:
partNumber
,
ETag
:
etag
},
nil
}
...
...
internal/sendfile/sendfile.go
View file @
41510837
...
...
@@ -132,7 +132,7 @@ func sendFileFromDisk(w http.ResponseWriter, r *http.Request, file string) {
if
contentTypeHeaderPresent
{
data
,
err
:=
ioutil
.
ReadAll
(
io
.
LimitReader
(
content
,
headers
.
MaxDetectSize
))
if
err
!=
nil
{
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"
error reading the file"
))
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"
content type detection: %v"
,
err
))
return
}
...
...
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