make trailing slash still work

This commit is contained in:
Megan Marsh 2018-07-11 19:01:45 -07:00
parent 36df317b89
commit 00eba7e894
1 changed files with 5 additions and 1 deletions

View File

@ -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)
}