From f968e2d45829adc64e318cdac049e0e9c3a259fe Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 21 Feb 2014 23:45:21 -0300 Subject: [PATCH] Improve check for whether we should warm up the cache or not --- lib/vagrant-cachier/bucket.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/vagrant-cachier/bucket.rb b/lib/vagrant-cachier/bucket.rb index d7a5fbd..cb7adfe 100644 --- a/lib/vagrant-cachier/bucket.rb +++ b/lib/vagrant-cachier/bucket.rb @@ -50,8 +50,7 @@ module VagrantPlugins comm.execute("mkdir -p #{bucket_path}") unless symlink?(guest_path) comm.sudo("mkdir -p `dirname #{guest_path}`") if create_parent - # Bucket is empty and guest path exists - if empty_dir?(bucket_path) && directory?(guest_path) + if empty_dir?(bucket_path) && !empty_dir?(guest_path) # Warm up cache with guest machine data comm.sudo("shopt -s dotglob && mv #{guest_path}/* #{bucket_path}") end @@ -68,8 +67,7 @@ module VagrantPlugins comm.execute("mkdir -p #{bucket_path}") unless symlink?(guest_path) comm.execute("mkdir -p `dirname #{guest_path}`") - # Bucket is empty and guest path exists - if empty_dir?(bucket_path) && directory?(guest_path) + if empty_dir?(bucket_path) && !empty_dir?(guest_path) # Warm up cache with guest machine data comm.execute("shopt -s dotglob && mv #{guest_path}/* #{bucket_path}") end @@ -85,10 +83,6 @@ module VagrantPlugins def symlink?(path) comm.test("test -L #{path}") end - - def directory?(path) - comm.test("test -d #{path}") - end end end end