Clean up logic surrounding file downloader matching

This commit is contained in:
Mitchell Hashimoto 2012-09-09 20:31:17 -07:00
parent e0e2cc1974
commit bb56f4dd31
2 changed files with 8 additions and 1 deletions

View File

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

View File

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