Merge pull request #4089 from ollama/mxyng/target-invalid

server: destination invalid
This commit is contained in:
Michael Yang 2024-05-01 12:46:35 -07:00 committed by GitHub
commit 5b806d8d24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 7 deletions

View file

@ -1125,7 +1125,7 @@ Environment Variables:
RunE: ListHandler, RunE: ListHandler,
} }
copyCmd := &cobra.Command{ copyCmd := &cobra.Command{
Use: "cp SOURCE TARGET", Use: "cp SOURCE DESTINATION",
Short: "Copy a model", Short: "Copy a model",
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
PreRunE: checkServerHeartbeat, PreRunE: checkServerHeartbeat,

View file

@ -810,16 +810,13 @@ func (s *Server) CopyModelHandler(c *gin.Context) {
src := model.ParseName(r.Source) src := model.ParseName(r.Source)
if !src.IsValid() { if !src.IsValid() {
_ = c.Error(fmt.Errorf("source %q is invalid", r.Source)) c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("source %q is invalid", r.Source)})
return
} }
dst := model.ParseName(r.Destination) dst := model.ParseName(r.Destination)
if !dst.IsValid() { if !dst.IsValid() {
_ = c.Error(fmt.Errorf("destination %q is invalid", r.Destination)) c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("destination %q is invalid", r.Source)})
}
if len(c.Errors) > 0 {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": c.Errors.Errors()})
return return
} }