diff --git a/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go b/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go index 3d6a7f5d2..4d089c13d 100644 --- a/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go +++ b/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go @@ -176,13 +176,35 @@ func cleanupContent(client *winrm.Client, filePath string) error { } defer shell.Close() - cmd, err := shell.Execute("powershell", "Remove-Item", filePath, "-ErrorAction SilentlyContinue") + script := fmt.Sprintf(` + $tmp_file_path = [System.IO.Path]::GetFullPath("%s") + if (Test-Path $tmp_file_path) { + Remove-Item $tmp_file_path -ErrorAction SilentlyContinue + } + `, filePath) + + cmd, err := shell.Execute(winrm.Powershell(script)) if err != nil { return err } + defer cmd.Close() + + var wg sync.WaitGroup + copyFunc := func(w io.Writer, r io.Reader) { + defer wg.Done() + io.Copy(w, r) + } + + wg.Add(2) + go copyFunc(os.Stdout, cmd.Stdout) + go copyFunc(os.Stderr, cmd.Stderr) cmd.Wait() - cmd.Close() + wg.Wait() + + if cmd.ExitCode() != 0 { + return fmt.Errorf("cleanup operation returned code=%d", cmd.ExitCode()) + } return nil } diff --git a/vendor/vendor.json b/vendor/vendor.json index f9a7b2935..1298f887d 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -2107,14 +2107,18 @@ { "checksumSHA1": "dIMJD0AZwSwmuOuTaGgqWZkzuPU=", "path": "github.com/packer-community/winrmcp", - "revision": "078cc0a785c9da54158c0775f06f505fc1e867f8", - "revisionTime": "2017-06-07T14:21:56Z" + "revision": "81144009af586de8e7729b829266f09dd0d59701", + "revisionTime": "2018-01-02T16:08:24Z", + "version": "master", + "versionExact": "master" }, { - "checksumSHA1": "iApv8tX8vuAvzyY6VkOvW+IzJF8=", + "checksumSHA1": "/NoE6t3UkW4/iKAtbf59GGv6tF8=", "path": "github.com/packer-community/winrmcp/winrmcp", - "revision": "078cc0a785c9da54158c0775f06f505fc1e867f8", - "revisionTime": "2017-06-07T14:21:56Z" + "revision": "81144009af586de8e7729b829266f09dd0d59701", + "revisionTime": "2018-01-02T16:08:24Z", + "version": "master", + "versionExact": "master" }, { "checksumSHA1": "rJab1YdNhQooDiBWNnt7TLWPyBU=",