allow for concurrent pulls of the same files

This commit is contained in:
Bruce MacDonald
2023-07-25 17:08:51 -04:00
parent 09d8bf6730
commit 868e3b31c7
3 changed files with 231 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
package server
import (
"context"
"encoding/json"
"errors"
"fmt"
@@ -200,7 +201,10 @@ func PullModelHandler(c *gin.Context) {
Password: req.Password,
}
if err := PullModel(req.Name, regOpts, fn); err != nil {
ctx, cancel := context.WithCancel(c.Request.Context())
defer cancel()
if err := PullModel(ctx, req.Name, regOpts, fn); err != nil {
ch <- gin.H{"error": err.Error()}
}
}()
@@ -250,7 +254,10 @@ func CreateModelHandler(c *gin.Context) {
ch <- resp
}
if err := CreateModel(req.Name, req.Path, fn); err != nil {
ctx, cancel := context.WithCancel(c.Request.Context())
defer cancel()
if err := CreateModel(ctx, req.Name, req.Path, fn); err != nil {
ch <- gin.H{"error": err.Error()}
}
}()