After 5 months I believe it is safe to get rid of this code

This commit is contained in:
Fabio Rehm 2014-01-02 01:13:09 -02:00
parent d77f5a6f18
commit d19ea59b8b
3 changed files with 4 additions and 79 deletions

View file

@ -1,5 +1,9 @@
## [0.6.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.5.1...master) (unreleased) ## [0.6.0](https://github.com/fgrehm/vagrant-cachier/compare/v0.5.1...master) (unreleased)
BACKWARDS INCOMPATIBILITY:
- Automatic handling of multiple machine scoped cache dirs from versions
prior to 0.3.0 of this plugin was removed.
## [0.5.1](https://github.com/fgrehm/vagrant-cachier/compare/v0.5.0...v0.5.1) (Dec 20, 2013) ## [0.5.1](https://github.com/fgrehm/vagrant-cachier/compare/v0.5.0...v0.5.1) (Dec 20, 2013)

View file

@ -1,64 +0,0 @@
require_relative '../errors'
module VagrantPlugins
module Cachier
class Action
class EnsureSingleCacheRoot
def initialize(app, env)
@app = app
end
def call(env)
@env = env
# If the cache is scoped to boxes or the existing cache dirs are not
# provider specific, there's nothing we need to do
if cache_scoped_to_machine? && provider_specific_cache_dirs.any?
ensure_single_cache_root_exists!
end
@app.call(env)
end
def cache_scoped_to_machine?
@env[:machine].config.cache.enabled? &&
@env[:machine].config.cache.scope.to_sym == :machine
end
def ensure_single_cache_root_exists!
if provider_specific_cache_dirs.size > 1
cache_dirs = provider_specific_cache_dirs.map do |dir|
" - #{dir.to_s.gsub(/^#{@env[:root_path]}\//, '')}"
end
machine_path = @env[:machine].data_dir.parent.to_s.gsub(/^#{@env[:root_path]}\//, '')
raise Cachier::Errors::MultipleProviderSpecificCacheDirsFound,
machine: @env[:machine].name,
machine_path: machine_path,
dirs: cache_dirs.join("\n")
else
current_path = provider_specific_cache_dirs.first.to_s.gsub(/^#{@env[:root_path]}\//, '')
new_path = @env[:machine].data_dir.parent.join('cache')
FileUtils.rm_rf new_path.to_s if new_path.directory?
new_path = new_path.to_s.gsub(/^#{@env[:root_path]}\//, '')
# If we got here there is a single provider specific cacher dir, so
# let's be nice with users and just fix it ;)
@env[:ui].warn I18n.t('vagrant_cachier.will_fix_machine_cache_dir',
current_path: current_path,
new_path: new_path)
FileUtils.mv current_path, new_path
end
end
def provider_specific_cache_dirs
return @provider_specific_cache_dirs if @provider_specific_cache_dirs
# By default data_dir points to ./.vagrant/machines/<NAME>/<PROVIDER>,
# so we go one directory up
machine_dir = @env[:machine].data_dir.parent
@provider_specific_cache_dirs = Pathname.glob(machine_dir.join('*/cache'))
end
end
end
end
end

View file

@ -70,21 +70,6 @@ module VagrantPlugins
Cap::SuSE::ZypperCacheDir Cap::SuSE::ZypperCacheDir
end end
# TODO: This should be generic, we don't want to hard code every single
# possible provider action class that Vagrant might have
ensure_single_cache_root = lambda do |hook|
require_relative 'action/ensure_single_cache_root'
hook.before VagrantPlugins::ProviderVirtualBox::Action::Boot, Action::EnsureSingleCacheRoot
if defined?(Vagrant::LXC)
# TODO: Require just the boot action file once its "require dependencies" are sorted out
require 'vagrant-lxc/action'
hook.before Vagrant::LXC::Action::Boot, Action::EnsureSingleCacheRoot
end
end
action_hook 'ensure-single-cache-root-exists-on-up', :machine_action_up, &ensure_single_cache_root
action_hook 'ensure-single-cache-root-exists-on-reload', :machine_action_reload, &ensure_single_cache_root
clean_action_hook = lambda do |hook| clean_action_hook = lambda do |hook|
require_relative 'action/clean' require_relative 'action/clean'
hook.before Vagrant::Action::Builtin::GracefulHalt, Action::Clean hook.before Vagrant::Action::Builtin::GracefulHalt, Action::Clean