From 1e2ce0e3e3b499b65cc63ed9da7831443efd11d6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 6 Dec 2013 18:31:45 -0800 Subject: [PATCH] common: allow files that don't exist to be URLs [GH-683] --- CHANGELOG.md | 1 + common/config.go | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f7d06a3e..8276b4c1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ BUG FIXES: * core: Don't change background color on CLI anymore, making things look a tad nicer in some terminals. +* core: multiple ISO URLs works properly in all builders. [GH-683] * builder/amazon/chroot: Block when obtaining file lock to allow parallel builds. [GH-689] * builder/vmware: Cleanup of VMX keys works properly so cd-rom won't diff --git a/common/config.go b/common/config.go index 460eeabc7..a0204eed2 100644 --- a/common/config.go +++ b/common/config.go @@ -105,21 +105,21 @@ func DownloadableURL(original string) (string, error) { url.Path = strings.Replace(url.Path, `\`, `/`, -1) } - if _, err := os.Stat(url.Path); err != nil { - return "", err - } + // Only do the filepath transformations if the file appears + // to actually exist. + if _, err := os.Stat(url.Path); err == nil { + url.Path, err = filepath.Abs(url.Path) + if err != nil { + return "", err + } - url.Path, err = filepath.Abs(url.Path) - if err != nil { - return "", err - } + url.Path, err = filepath.EvalSymlinks(url.Path) + if err != nil { + return "", err + } - url.Path, err = filepath.EvalSymlinks(url.Path) - if err != nil { - return "", err + url.Path = filepath.Clean(url.Path) } - - url.Path = filepath.Clean(url.Path) } // Make sure it is lowercased