mirror of
https://github.com/ollama/ollama.git
synced 2025-11-12 19:17:27 +01:00
cache and reuse intermediate blobs
particularly useful for zipfiles and f16s
This commit is contained in:
@@ -841,6 +841,25 @@ func (s *Server) HeadBlobHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (s *Server) CreateBlobHandler(c *gin.Context) {
|
||||
ib, ok := intermediateBlobs.Load(c.Param("digest"))
|
||||
if ok {
|
||||
p, err := GetBlobsPath(ib.(string))
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := os.Stat(p); errors.Is(err, os.ErrNotExist) {
|
||||
intermediateBlobs.Delete(c.Param("digest"))
|
||||
} else if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
} else {
|
||||
c.Status(http.StatusOK)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
path, err := GetBlobsPath(c.Param("digest"))
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
|
||||
Reference in New Issue
Block a user