From b78be4625dd7348f378fafd78d3f08180da38364 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 23 Nov 2013 15:53:45 -0800 Subject: [PATCH] core: remove old temp files for boxes --- lib/vagrant/action/builtin/box_add.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/vagrant/action/builtin/box_add.rb b/lib/vagrant/action/builtin/box_add.rb index b132ef202..a6c44e8d4 100644 --- a/lib/vagrant/action/builtin/box_add.rb +++ b/lib/vagrant/action/builtin/box_add.rb @@ -33,6 +33,13 @@ module Vagrant downloader_options[:insecure] = env[:box_download_insecure] downloader_options[:ui] = env[:ui] + # If the temporary path exists, verify it is not too old. If its + # too old, delete it first because the data may have changed. + if @temp_path.file? && @temp_path.mtime.to_i < (Time.now.to_i - 6 * 60 * 60) + @logger.info("Existing temp file is too old. Removing.") + @temp_path.unlink + end + # Download the box to a temporary path. We store the temporary # path as an instance variable so that the `#recover` method can # access it.