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
434a6f9d
Commit
434a6f9d
authored
Nov 03, 2023
by
Michael Yang
Browse files
return last error
parent
84725ec7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
server/download.go
server/download.go
+3
-2
server/upload.go
server/upload.go
+5
-4
No files found.
server/download.go
View file @
434a6f9d
...
...
@@ -149,9 +149,10 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *Regis
i
:=
i
g
.
Go
(
func
()
error
{
var
err
error
for
try
:=
0
;
try
<
maxRetries
;
try
++
{
w
:=
io
.
NewOffsetWriter
(
file
,
part
.
StartsAt
())
err
:
=
b
.
downloadChunk
(
inner
,
requestURL
,
w
,
part
,
opts
)
err
=
b
.
downloadChunk
(
inner
,
requestURL
,
w
,
part
,
opts
)
switch
{
case
errors
.
Is
(
err
,
context
.
Canceled
),
errors
.
Is
(
err
,
syscall
.
ENOSPC
)
:
// return immediately if the context is canceled or the device is out of space
...
...
@@ -164,7 +165,7 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *Regis
}
}
return
errMaxRetriesExceeded
return
fmt
.
Errorf
(
"%w: %w"
,
errMaxRetriesExceeded
,
err
)
})
}
...
...
server/upload.go
View file @
434a6f9d
...
...
@@ -135,9 +135,10 @@ func (b *blobUpload) Run(ctx context.Context, opts *RegistryOptions) {
case
<-
inner
.
Done
()
:
case
requestURL
:=
<-
b
.
nextURL
:
g
.
Go
(
func
()
error
{
var
err
error
for
try
:=
0
;
try
<
maxRetries
;
try
++
{
part
.
ReadSeeker
=
io
.
NewSectionReader
(
f
,
part
.
Offset
,
part
.
Size
)
err
:
=
b
.
uploadChunk
(
inner
,
http
.
MethodPatch
,
requestURL
,
part
,
opts
)
err
=
b
.
uploadChunk
(
inner
,
http
.
MethodPatch
,
requestURL
,
part
,
opts
)
switch
{
case
errors
.
Is
(
err
,
context
.
Canceled
)
:
return
err
...
...
@@ -151,7 +152,7 @@ func (b *blobUpload) Run(ctx context.Context, opts *RegistryOptions) {
return
nil
}
return
errMaxRetriesExceeded
return
fmt
.
Errorf
(
"%w: %w"
,
errMaxRetriesExceeded
,
err
)
})
}
}
...
...
@@ -227,7 +228,7 @@ func (b *blobUpload) uploadChunk(ctx context.Context, method string, requestURL
}
for
try
:=
0
;
try
<
maxRetries
;
try
++
{
err
:
=
b
.
uploadChunk
(
ctx
,
http
.
MethodPut
,
redirectURL
,
part
,
nil
)
err
=
b
.
uploadChunk
(
ctx
,
http
.
MethodPut
,
redirectURL
,
part
,
nil
)
switch
{
case
errors
.
Is
(
err
,
context
.
Canceled
)
:
return
err
...
...
@@ -241,7 +242,7 @@ func (b *blobUpload) uploadChunk(ctx context.Context, method string, requestURL
return
nil
}
return
errMaxRetriesExceeded
return
fmt
.
Errorf
(
"%w: %w"
,
errMaxRetriesExceeded
,
err
)
case
resp
.
StatusCode
==
http
.
StatusUnauthorized
:
auth
:=
resp
.
Header
.
Get
(
"www-authenticate"
)
...
...
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