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) Upstream-commit: 9e69a042c50a3706c847addd68469dfe3eb698a0 Component: engine
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user