mirror of
https://github.com/tcsenpai/ollama.git
synced 2025-06-06 19:25:21 +00:00
types/model: accept former :
as a separator in digest (#3724)
This also converges the old sep `:` to the new sep `-`.
This commit is contained in:
parent
63a7edd771
commit
0408205c1c
@ -1,6 +1,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
@ -47,8 +48,11 @@ var (
|
|||||||
// Digest.
|
// Digest.
|
||||||
func ParseDigest(s string) Digest {
|
func ParseDigest(s string) Digest {
|
||||||
typ, digest, ok := strings.Cut(s, "-")
|
typ, digest, ok := strings.Cut(s, "-")
|
||||||
|
if !ok {
|
||||||
|
typ, digest, ok = strings.Cut(s, ":")
|
||||||
|
}
|
||||||
if ok && isValidDigestType(typ) && isValidHex(digest) {
|
if ok && isValidDigestType(typ) && isValidHex(digest) {
|
||||||
return Digest{s: s}
|
return Digest{s: fmt.Sprintf("%s-%s", typ, digest)}
|
||||||
}
|
}
|
||||||
return Digest{}
|
return Digest{}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user