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
e1c9a2a0
"docs/vscode:/vscode.git/clone" did not exist on "0bdd57ccb20e9690b95c2fa02315d9507afa69dd"
Commit
e1c9a2a0
authored
Apr 05, 2024
by
Michael Yang
Browse files
no blob create if already exists
parent
1341ee1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
api/client.go
api/client.go
+1
-13
server/routes.go
server/routes.go
+18
-0
No files found.
api/client.go
View file @
e1c9a2a0
...
...
@@ -5,7 +5,6 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net"
...
...
@@ -301,18 +300,7 @@ func (c *Client) Embeddings(ctx context.Context, req *EmbeddingRequest) (*Embedd
}
func
(
c
*
Client
)
CreateBlob
(
ctx
context
.
Context
,
digest
string
,
r
io
.
Reader
)
error
{
if
err
:=
c
.
do
(
ctx
,
http
.
MethodHead
,
fmt
.
Sprintf
(
"/api/blobs/%s"
,
digest
),
nil
,
nil
);
err
!=
nil
{
var
statusError
StatusError
if
!
errors
.
As
(
err
,
&
statusError
)
||
statusError
.
StatusCode
!=
http
.
StatusNotFound
{
return
err
}
if
err
:=
c
.
do
(
ctx
,
http
.
MethodPost
,
fmt
.
Sprintf
(
"/api/blobs/%s"
,
digest
),
r
,
nil
);
err
!=
nil
{
return
err
}
}
return
nil
return
c
.
do
(
ctx
,
http
.
MethodPost
,
fmt
.
Sprintf
(
"/api/blobs/%s"
,
digest
),
r
,
nil
)
}
func
(
c
*
Client
)
Version
(
ctx
context
.
Context
)
(
string
,
error
)
{
...
...
server/routes.go
View file @
e1c9a2a0
...
...
@@ -913,6 +913,24 @@ func HeadBlobHandler(c *gin.Context) {
}
func
CreateBlobHandler
(
c
*
gin
.
Context
)
{
path
,
err
:=
GetBlobsPath
(
c
.
Param
(
"digest"
))
if
err
!=
nil
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
_
,
err
=
os
.
Stat
(
path
)
switch
{
case
errors
.
Is
(
err
,
os
.
ErrNotExist
)
:
// noop
case
err
!=
nil
:
c
.
AbortWithStatusJSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
default
:
c
.
Status
(
http
.
StatusOK
)
return
}
layer
,
err
:=
NewLayer
(
c
.
Request
.
Body
,
""
)
if
err
!=
nil
{
c
.
AbortWithStatusJSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
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