fix(windows): modelpath and list
This commit is contained in:
parent
2bb2bdd5d4
commit
2b9892a808
2 changed files with 9 additions and 8 deletions
|
@ -46,7 +46,7 @@ func ParseModelPath(name string) ModelPath {
|
|||
name = after
|
||||
}
|
||||
|
||||
parts := strings.Split(name, string(os.PathSeparator))
|
||||
parts := strings.Split(name, "/")
|
||||
switch len(parts) {
|
||||
case 3:
|
||||
mp.Registry = parts[0]
|
||||
|
|
|
@ -711,7 +711,7 @@ func GetModelInfo(req api.ShowRequest) (*api.ShowResponse, error) {
|
|||
|
||||
func ListModelsHandler(c *gin.Context) {
|
||||
models := make([]api.ModelResponse, 0)
|
||||
fp, err := GetManifestPath()
|
||||
manifestsPath, err := GetManifestPath()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
|
@ -741,13 +741,14 @@ func ListModelsHandler(c *gin.Context) {
|
|||
|
||||
walkFunc := func(path string, info os.FileInfo, _ error) error {
|
||||
if !info.IsDir() {
|
||||
dir, file := filepath.Split(path)
|
||||
dir = strings.Trim(strings.TrimPrefix(dir, fp), string(os.PathSeparator))
|
||||
tag := strings.Join([]string{dir, file}, ":")
|
||||
path, tag := filepath.Split(path)
|
||||
model := strings.Trim(strings.TrimPrefix(path, manifestsPath), string(os.PathSeparator))
|
||||
modelPath := strings.Join([]string{model, tag}, ":")
|
||||
canonicalModelPath := strings.ReplaceAll(modelPath, string(os.PathSeparator), "/")
|
||||
|
||||
resp, err := modelResponse(tag)
|
||||
resp, err := modelResponse(canonicalModelPath)
|
||||
if err != nil {
|
||||
log.Printf("skipping file: %s", fp)
|
||||
log.Printf("skipping file: %s", canonicalModelPath)
|
||||
// nolint: nilerr
|
||||
return nil
|
||||
}
|
||||
|
@ -759,7 +760,7 @@ func ListModelsHandler(c *gin.Context) {
|
|||
return nil
|
||||
}
|
||||
|
||||
if err := filepath.Walk(fp, walkFunc); err != nil {
|
||||
if err := filepath.Walk(manifestsPath, walkFunc); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue