Merge pull request #2102 from jmorganca/mxyng/fix-create-override

fix: remove overwritten model layers
This commit is contained in:
Michael Yang 2024-01-22 09:37:48 -08:00 committed by GitHub
commit 6225fde046
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -412,6 +412,13 @@ func realpath(mfDir, from string) string {
} }
func CreateModel(ctx context.Context, name, modelFileDir string, commands []parser.Command, fn func(resp api.ProgressResponse)) error { func CreateModel(ctx context.Context, name, modelFileDir string, commands []parser.Command, fn func(resp api.ProgressResponse)) error {
deleteMap := make(map[string]struct{})
if manifest, _, err := GetManifest(ParseModelPath(name)); err == nil {
for _, layer := range append(manifest.Layers, manifest.Config) {
deleteMap[layer.Digest] = struct{}{}
}
}
config := ConfigV2{ config := ConfigV2{
OS: "linux", OS: "linux",
Architecture: "amd64", Architecture: "amd64",
@ -420,8 +427,6 @@ func CreateModel(ctx context.Context, name, modelFileDir string, commands []pars
}, },
} }
deleteMap := make(map[string]struct{})
var layers Layers var layers Layers
params := make(map[string][]string) params := make(map[string][]string)