From 96a637684b2683c4df0e6648b5bbfec9f9c5c0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E6=81=92?= Date: Mon, 19 Sep 2016 10:36:18 +0800 Subject: [PATCH] fix #3897 bug fix for file-provisioner download file, including unit-test code. --- provisioner/file/provisioner.go | 2 +- provisioner/file/provisioner_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index 2b9a6b5fe..49498d08d 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -109,7 +109,7 @@ func (p *Provisioner) ProvisionDownload(ui packer.Ui, comm packer.Communicator) } } // if the config.Destination was a dir, download the dir - if !strings.HasSuffix(p.config.Destination, "/") { + if strings.HasSuffix(p.config.Destination, "/") { return comm.DownloadDir(src, p.config.Destination, nil) } diff --git a/provisioner/file/provisioner_test.go b/provisioner/file/provisioner_test.go index 53dc315d4..2169c96a3 100644 --- a/provisioner/file/provisioner_test.go +++ b/provisioner/file/provisioner_test.go @@ -192,5 +192,9 @@ func TestProvisionDownloadMkdirAll(t *testing.T) { if _, err := os.Stat(path); err != nil { t.Fatalf("stat of download dir should not error: %s", err) } + + if _, err := os.Stat(config["destination"].(string)); err != nil { + t.Fatalf("stat of destination file should not error: %s", err) + } } }