From 00eba7e8944f2b0108e935e9aa2096e06f2d4d4c Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 11 Jul 2018 19:01:45 -0700 Subject: [PATCH] make trailing slash still work --- communicator/winrm/communicator.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/communicator/winrm/communicator.go b/communicator/winrm/communicator.go index bab2ebde2..fc639ccb0 100644 --- a/communicator/winrm/communicator.go +++ b/communicator/winrm/communicator.go @@ -122,11 +122,15 @@ func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) { } // Upload implementation of communicator.Communicator interface -func (c *Communicator) Upload(path string, input io.Reader, _ *os.FileInfo) error { +func (c *Communicator) Upload(path string, input io.Reader, fi *os.FileInfo) error { wcp, err := c.newCopyClient() if err != nil { return fmt.Errorf("Was unable to create winrm client: %s", err) } + if strings.HasSuffix(path, `\`) { + // path is a directory + path += filepath.Base((*fi).Name()) + } log.Printf("Uploading file to '%s'", path) return wcp.Write(path, input) }