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
cb425897
Commit
cb425897
authored
Nov 17, 2023
by
Michael Yang
Committed by
Jeffrey Morgan
Nov 19, 2023
Browse files
adjust download/upload parts
parent
258addc7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
server/download.go
server/download.go
+6
-4
server/upload.go
server/upload.go
+5
-3
No files found.
server/download.go
View file @
cb425897
...
@@ -53,8 +53,8 @@ type blobDownloadPart struct {
...
@@ -53,8 +53,8 @@ type blobDownloadPart struct {
const
(
const
(
numDownloadParts
=
64
numDownloadParts
=
64
minDownloadPartSize
int64
=
32
*
1000
*
1000
minDownloadPartSize
int64
=
100
*
format
.
MegaByte
maxDownloadPartSize
int64
=
256
*
1000
*
1000
maxDownloadPartSize
int64
=
1000
*
format
.
MegaByte
)
)
func
(
p
*
blobDownloadPart
)
Name
()
string
{
func
(
p
*
blobDownloadPart
)
Name
()
string
{
...
@@ -158,7 +158,9 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *Regis
...
@@ -158,7 +158,9 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *Regis
// return immediately if the context is canceled or the device is out of space
// return immediately if the context is canceled or the device is out of space
return
err
return
err
case
err
!=
nil
:
case
err
!=
nil
:
log
.
Printf
(
"%s part %d attempt %d failed: %v, retrying"
,
b
.
Digest
[
7
:
19
],
i
,
try
,
err
)
sleep
:=
200
*
time
.
Millisecond
+
time
.
Duration
(
try
)
*
time
.
Second
/
4
log
.
Printf
(
"%s part %d attempt %d failed: %v, retrying in %s"
,
b
.
Digest
[
7
:
19
],
i
,
try
,
err
,
sleep
)
time
.
Sleep
(
sleep
)
continue
continue
default
:
default
:
if
try
>
0
{
if
try
>
0
{
...
@@ -304,7 +306,7 @@ type downloadOpts struct {
...
@@ -304,7 +306,7 @@ type downloadOpts struct {
fn
func
(
api
.
ProgressResponse
)
fn
func
(
api
.
ProgressResponse
)
}
}
const
maxRetries
=
3
const
maxRetries
=
10
var
errMaxRetriesExceeded
=
errors
.
New
(
"max retries exceeded"
)
var
errMaxRetriesExceeded
=
errors
.
New
(
"max retries exceeded"
)
...
...
server/upload.go
View file @
cb425897
...
@@ -42,8 +42,8 @@ type blobUpload struct {
...
@@ -42,8 +42,8 @@ type blobUpload struct {
const
(
const
(
numUploadParts
=
64
numUploadParts
=
64
minUploadPartSize
int64
=
95
*
1000
*
1000
minUploadPartSize
int64
=
100
*
format
.
MegaByte
maxUploadPartSize
int64
=
1000
*
1000
*
1000
maxUploadPartSize
int64
=
1000
*
format
.
MegaByte
)
)
func
(
b
*
blobUpload
)
Prepare
(
ctx
context
.
Context
,
requestURL
*
url
.
URL
,
opts
*
RegistryOptions
)
error
{
func
(
b
*
blobUpload
)
Prepare
(
ctx
context
.
Context
,
requestURL
*
url
.
URL
,
opts
*
RegistryOptions
)
error
{
...
@@ -153,7 +153,9 @@ func (b *blobUpload) Run(ctx context.Context, opts *RegistryOptions) {
...
@@ -153,7 +153,9 @@ func (b *blobUpload) Run(ctx context.Context, opts *RegistryOptions) {
case
errors
.
Is
(
err
,
errMaxRetriesExceeded
)
:
case
errors
.
Is
(
err
,
errMaxRetriesExceeded
)
:
return
err
return
err
case
err
!=
nil
:
case
err
!=
nil
:
log
.
Printf
(
"%s part %d attempt %d failed: %v, retrying"
,
b
.
Digest
[
7
:
19
],
part
.
N
,
try
,
err
)
sleep
:=
200
*
time
.
Millisecond
+
time
.
Duration
(
try
)
*
time
.
Second
/
4
log
.
Printf
(
"%s part %d attempt %d failed: %v, retrying in %s"
,
b
.
Digest
[
7
:
19
],
part
.
N
,
try
,
err
,
sleep
)
time
.
Sleep
(
sleep
)
continue
continue
}
}
...
...
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