fix nasty edge case where we can't find guest additions on windows if they are on a different drive

This commit is contained in:
Megan Marsh 2018-01-03 14:34:11 -08:00
parent a8e30bc796
commit 54bd057bb9
2 changed files with 6 additions and 6 deletions

View File

@ -74,12 +74,6 @@ func DownloadableURL(original string) (string, error) {
url.Path = url.Host
url.Host = ""
}
// For Windows absolute file paths, remove leading / prior to processing
// since net/url turns "C:/" into "/C:/"
if len(url.Path) > 0 && url.Path[0] == '/' {
url.Path = url.Path[1:len(url.Path)]
}
}
// Only do the filepath transformations if the file appears

View File

@ -15,6 +15,7 @@ import (
"net/http"
"net/url"
"os"
"runtime"
)
// DownloadConfig is the configuration given to instantiate a new
@ -129,6 +130,11 @@ func (d *DownloadClient) Get() (string, error) {
// locally and we don't make a copy. Normally we would copy or download.
log.Printf("[DEBUG] Using local file: %s", finalPath)
// Remove forward slash on absolute Windows file URLs before processing
if runtime.GOOS == "windows" && len(finalPath) > 0 && finalPath[0] == '/' {
finalPath = finalPath[1:]
}
// Keep track of the source so we can make sure not to delete this later
sourcePath = finalPath
if _, err = os.Stat(finalPath); err != nil {