1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix docker cp trying to untar files that do not exist.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <erik@hollensbe.org> (github: erikh)
This commit is contained in:
Erik Hollensbe 2014-03-16 17:48:46 +00:00
parent 7a7126faf6
commit 9e69a042c5

View file

@ -894,6 +894,9 @@ func postContainersCopy(eng *engine.Engine, version version.Version, w http.Resp
if copyData.Get("Resource") == "" {
return fmt.Errorf("Path cannot be empty")
}
origResource := copyData.Get("Resource")
if copyData.Get("Resource")[0] == '/' {
copyData.Set("Resource", copyData.Get("Resource")[1:])
}
@ -904,6 +907,8 @@ func postContainersCopy(eng *engine.Engine, version version.Version, w http.Resp
utils.Errorf("%s", err.Error())
if strings.Contains(err.Error(), "No such container") {
w.WriteHeader(http.StatusNotFound)
} else if strings.Contains(err.Error(), "no such file or directory") {
return fmt.Errorf("Could not find the file %s in container %s", origResource, vars["name"])
}
}
return nil