Restore original lines in setup_buckets_folder. Add final logic for determining base_path to use for caching

This commit is contained in:
Avi Oza 2017-05-02 19:35:34 -04:00
parent 67217fff02
commit fa581a325e

View file

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