Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
42c2e3a6
Commit
42c2e3a6
authored
Nov 17, 2023
by
Michael Yang
Committed by
Jeffrey Morgan
Nov 19, 2023
Browse files
upload: retry complete upload
parent
cb425897
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
server/upload.go
server/upload.go
+13
-6
No files found.
server/upload.go
View file @
42c2e3a6
...
@@ -190,14 +190,21 @@ func (b *blobUpload) Run(ctx context.Context, opts *RegistryOptions) {
...
@@ -190,14 +190,21 @@ func (b *blobUpload) Run(ctx context.Context, opts *RegistryOptions) {
headers
.
Set
(
"Content-Type"
,
"application/octet-stream"
)
headers
.
Set
(
"Content-Type"
,
"application/octet-stream"
)
headers
.
Set
(
"Content-Length"
,
"0"
)
headers
.
Set
(
"Content-Length"
,
"0"
)
resp
,
err
:=
makeRequestWithRetry
(
ctx
,
http
.
MethodPut
,
requestURL
,
headers
,
nil
,
opts
)
for
try
:=
0
;
try
<
maxRetries
;
try
++
{
if
err
!=
nil
{
resp
,
err
:=
makeRequestWithRetry
(
ctx
,
http
.
MethodPut
,
requestURL
,
headers
,
nil
,
opts
)
b
.
err
=
err
if
err
!=
nil
{
b
.
err
=
err
sleep
:=
200
*
time
.
Millisecond
+
time
.
Duration
(
try
)
*
time
.
Second
/
4
log
.
Printf
(
"%s complete upload attempt %d failed: %v, retrying in %s"
,
b
.
Digest
[
7
:
19
],
try
,
err
,
sleep
)
time
.
Sleep
(
sleep
)
continue
}
defer
resp
.
Body
.
Close
()
b
.
err
=
nil
b
.
done
=
true
return
return
}
}
defer
resp
.
Body
.
Close
()
b
.
done
=
true
}
}
func
(
b
*
blobUpload
)
uploadChunk
(
ctx
context
.
Context
,
method
string
,
requestURL
*
url
.
URL
,
part
*
blobUploadPart
,
opts
*
RegistryOptions
)
error
{
func
(
b
*
blobUpload
)
uploadChunk
(
ctx
context
.
Context
,
method
string
,
requestURL
*
url
.
URL
,
part
*
blobUploadPart
,
opts
*
RegistryOptions
)
error
{
...
...
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