forked from third-party-mirrors/ollama
server: update checkNameExists to use case-insensitive name comparison
This allows pulls, pushes, and other model operations to be performed with mixed-case names, which the Ollama registry supports.
This commit is contained in:
parent
d7eb05b936
commit
d1b033c168
@ -628,7 +628,7 @@ func checkNameExists(name model.Name) error {
|
||||
}
|
||||
|
||||
for n := range names {
|
||||
if strings.EqualFold(n.Filepath(), name.Filepath()) && n != name {
|
||||
if strings.EqualFold(n.Filepath(), name.Filepath()) && n.EqualFold(name) {
|
||||
return errors.New("a model with that name already exists")
|
||||
}
|
||||
}
|
||||
|
@ -298,6 +298,13 @@ func (n Name) LogValue() slog.Value {
|
||||
return slog.StringValue(n.String())
|
||||
}
|
||||
|
||||
func (n Name) EqualFold(o Name) bool {
|
||||
return strings.EqualFold(n.Host, o.Host) &&
|
||||
strings.EqualFold(n.Namespace, o.Namespace) &&
|
||||
strings.EqualFold(n.Model, o.Model) &&
|
||||
strings.EqualFold(n.Tag, o.Tag)
|
||||
}
|
||||
|
||||
func isValidLen(kind partKind, s string) bool {
|
||||
switch kind {
|
||||
case kindHost:
|
||||
|
Loading…
x
Reference in New Issue
Block a user