mirror of
https://github.com/ollama/ollama.git
synced 2025-05-12 10:57:05 +02:00
server: replace blob prefix separator from ':' to '-' (#3146)
This fixes issues with blob file names that contain ':' characters to be rejected by file systems that do not support them.
This commit is contained in:
parent
6459377ae0
commit
703684a82a
6 changed files with 120 additions and 13 deletions
26
server/fixblobs.go
Normal file
26
server/fixblobs.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// fixBlobs walks the provided dir and replaces (":") to ("-") in the file
|
||||
// prefix. (e.g. sha256:1234 -> sha256-1234)
|
||||
func fixBlobs(dir string) error {
|
||||
return filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
baseName := filepath.Base(path)
|
||||
typ, sha, ok := strings.Cut(baseName, ":")
|
||||
if ok && typ == "sha256" {
|
||||
newPath := filepath.Join(filepath.Dir(path), typ+"-"+sha)
|
||||
if err := os.Rename(path, newPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue