mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #4701 from erikh/4099-non_existent_file_no_error
Fix `docker cp` trying to untar files that do not exist.
This commit is contained in:
commit
2ada6441db
1 changed files with 5 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue