mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 21:51:33 +00:00
Removed engine from /copy
* Client and server use types.CopyConfig * API calls container.Copy directly Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
+8
-10
@@ -5,7 +5,7 @@ import (
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/engine"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
flag "github.com/docker/docker/pkg/mflag"
|
||||
)
|
||||
@@ -21,17 +21,16 @@ func (cli *DockerCli) CmdCp(args ...string) error {
|
||||
|
||||
cmd.ParseFlags(args, true)
|
||||
|
||||
var copyData engine.Env
|
||||
info := strings.Split(cmd.Arg(0), ":")
|
||||
|
||||
if len(info) != 2 {
|
||||
return fmt.Errorf("Error: Path not specified")
|
||||
}
|
||||
|
||||
copyData.Set("Resource", info[1])
|
||||
copyData.Set("HostPath", cmd.Arg(1))
|
||||
|
||||
stream, statusCode, err := cli.call("POST", "/containers/"+info[0]+"/copy", copyData, nil)
|
||||
cfg := &types.CopyConfig{
|
||||
Resource: info[1],
|
||||
}
|
||||
stream, statusCode, err := cli.call("POST", "/containers/"+info[0]+"/copy", cfg, nil)
|
||||
if stream != nil {
|
||||
defer stream.Close()
|
||||
}
|
||||
@@ -42,13 +41,12 @@ func (cli *DockerCli) CmdCp(args ...string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
hostPath := cmd.Arg(1)
|
||||
if statusCode == 200 {
|
||||
dest := copyData.Get("HostPath")
|
||||
|
||||
if dest == "-" {
|
||||
if hostPath == "-" {
|
||||
_, err = io.Copy(cli.out, stream)
|
||||
} else {
|
||||
err = archive.Untar(stream, dest, &archive.TarOptions{NoLchown: true})
|
||||
err = archive.Untar(stream, hostPath, &archive.TarOptions{NoLchown: true})
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user