From 4259b8f2f63983b0d9388a6dc556e484b9ed7949 Mon Sep 17 00:00:00 2001 From: Nithin Philips Date: Mon, 11 Nov 2013 11:50:55 -0500 Subject: [PATCH] Handling file:// urls. This extends support to UNC paths. --- lib/vagrant-box-updater/util/common.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/vagrant-box-updater/util/common.rb b/lib/vagrant-box-updater/util/common.rb index 89aa91b..f5f3e5f 100644 --- a/lib/vagrant-box-updater/util/common.rb +++ b/lib/vagrant-box-updater/util/common.rb @@ -1,3 +1,5 @@ +require 'open-uri' + module VagrantPlugins module BoxUpdater module Util @@ -66,6 +68,13 @@ def self.fetch_url(uri_str, limit = 10) end def self.get_local_file_modification_date?(url) + # Sometimes local files can be referenced by a file:// URL. + # Cleanup the path so that File.mtime can handle the file. + if url.start_with?("file://") + url = url.slice(7..-1) + url = URI::decode(url) + end + mtime = File.mtime(url) return { 'Last-Modified' => mtime } end