From fa581a325e3fff12a50fef194037d7386b972ec3 Mon Sep 17 00:00:00 2001 From: Avi Oza Date: Tue, 2 May 2017 19:35:34 -0400 Subject: [PATCH] Restore original lines in setup_buckets_folder. Add final logic for determining base_path to use for caching --- .../action/configure_bucket_root.rb | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/vagrant-cachier/action/configure_bucket_root.rb b/lib/vagrant-cachier/action/configure_bucket_root.rb index 37aa8a8..3fff239 100644 --- a/lib/vagrant-cachier/action/configure_bucket_root.rb +++ b/lib/vagrant-cachier/action/configure_bucket_root.rb @@ -21,14 +21,13 @@ module VagrantPlugins end def setup_buckets_folder + FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist? synced_folder_opts = {id: "vagrant-cache"} synced_folder_opts.merge!(@env[:machine].config.cache.synced_folder_opts || {}) - puts([@env[:machine].config.cache.override_directory, cache_root].join('')) - FileUtils.mkdir_p([@env[:machine].config.cache.override_directory, cache_root].join('').to_s) unless File.directory?([@env[:machine].config.cache.override_directory, cache_root].join('').to_s) - @env[:machine].config.vm.synced_folder [@env[:machine].config.cache.override_directory, cache_root].join(''), '/tmp/vagrant-cache', synced_folder_opts + @env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', synced_folder_opts @env[:cache_dirs] = [] end @@ -48,9 +47,22 @@ module VagrantPlugins else bucket_name = @box_name end - @env[:home_path].join('cache', bucket_name) + # An override directory has been specified. Use this as the base instead of the standard directory + if !@env[:machine].config.cache.override_directory.nil? + base_path = Pathname.new(@env[:machine].config.cache.override_directory) + else + base_path = @env[:home_path] + end + base_path.join('cache', bucket_name) when :machine - @env[:machine].data_dir.parent.join('cache') + # An override directory has been specified. Use this as the base instead of the standard directory + if !@env[:machine].config.cache.override_directory.nil? + base_path = Pathname.new(@env[:machine].config.cache.override_directory) + base_path += @env[:machine].name.to_s + else + base_path = @env[:machine].data_dir.parent + end + base_path.join('cache') else raise "Unknown cache scope: '#{@env[:machine].config.cache.scope}'" end