From bb56f4dd317637f7b9b9978c28c44d5b0c1ae258 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 9 Sep 2012 20:31:17 -0700 Subject: [PATCH] Clean up logic surrounding file downloader matching --- CHANGELOG.md | 1 + lib/vagrant/downloaders/file.rb | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 116194a98..ee9fc108d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ - Add missing translation for "saving" state on VirtualBox. [GH-1110] - Proper error message if the remote end unexpectedly resets the connection while downloading a box over HTTP. [GH-1090] + - Allow "file://" URLs for box URLs. [GH-1087] ## 1.0.3 (May 1, 2012) diff --git a/lib/vagrant/downloaders/file.rb b/lib/vagrant/downloaders/file.rb index 9521bae45..e4c6891b6 100644 --- a/lib/vagrant/downloaders/file.rb +++ b/lib/vagrant/downloaders/file.rb @@ -8,7 +8,13 @@ module Vagrant class File < Base def self.match?(uri) extracted = URI.extract(uri, "file") - (extracted && extracted.include?(uri)) || ::File.file?(::File.expand_path(uri)) + + # We match if we got a file URI. It doesn't matter here if the file + # doesn't exist because we check again later as well. + return true if extracted && extracted.include?(uri) + + # Otherwise we match if the file exists + return ::File.file?(::File.expand_path(uri)) end def download!(source_url, destination_file)