add copy command (#191)

This commit is contained in:
Patrick Devine
2023-07-24 11:27:28 -04:00
committed by GitHub
parent ec5e22ac85
commit 4cb42ca55e
5 changed files with 77 additions and 2 deletions

View File

@@ -493,6 +493,32 @@ func CreateLayer(f io.ReadSeeker) (*LayerReader, error) {
return layer, nil
}
func CopyModel(src, dest string) error {
srcPath, err := ParseModelPath(src).GetManifestPath(false)
if err != nil {
return err
}
destPath, err := ParseModelPath(dest).GetManifestPath(true)
if err != nil {
return err
}
// copy the file
input, err := ioutil.ReadFile(srcPath)
if err != nil {
fmt.Println("Error reading file:", err)
return err
}
err = ioutil.WriteFile(destPath, input, 0644)
if err != nil {
fmt.Println("Error reading file:", err)
return err
}
return nil
}
func DeleteModel(name string) error {
mp := ParseModelPath(name)