use checksum reference

This commit is contained in:
Michael Yang
2023-11-15 10:59:38 -08:00
parent d660eebf22
commit 1901044b07
4 changed files with 20 additions and 12 deletions

View File

@@ -287,6 +287,15 @@ func CreateModel(ctx context.Context, name string, commands []parser.Command, fn
switch c.Name {
case "model":
if strings.HasPrefix(c.Args, "@") {
blobPath, err := GetBlobsPath(strings.TrimPrefix(c.Args, "@"))
if err != nil {
return err
}
c.Args = blobPath
}
bin, err := os.Open(realpath(c.Args))
if err != nil {
// not a file on disk so must be a model reference

View File

@@ -650,7 +650,7 @@ func CopyModelHandler(c *gin.Context) {
}
}
func GetBlobHandler(c *gin.Context) {
func HeadBlobHandler(c *gin.Context) {
path, err := GetBlobsPath(c.Param("digest"))
if err != nil {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()})
@@ -771,9 +771,10 @@ func Serve(ln net.Listener, allowOrigins []string) error {
})
r.Handle(method, "/api/tags", ListModelsHandler)
r.Handle(method, "/api/blobs/:digest/path", GetBlobHandler)
}
r.HEAD("/api/blobs/:digest", HeadBlobHandler)
log.Printf("Listening on %s (version %s)", ln.Addr(), version.Version)
s := &http.Server{
Handler: r,