diff --git a/plugins/synced_folders/nfs/action_cleanup.rb b/plugins/synced_folders/nfs/action_cleanup.rb index 6c1b72d76..d2c7f6b42 100644 --- a/plugins/synced_folders/nfs/action_cleanup.rb +++ b/plugins/synced_folders/nfs/action_cleanup.rb @@ -14,6 +14,11 @@ module VagrantPlugins return @app.call(env) end + if !env[:machine].env.host.capability?(:nfs_prune) + @logger.info("Host doesn't support pruning NFS. Skipping.") + return @app.call(env) + end + @logger.info("NFS pruning. Valid IDs: #{env[:nfs_valid_ids].inspect}") env[:machine].env.host.capability( :nfs_prune, env[:machine].ui, env[:nfs_valid_ids]) diff --git a/test/unit/plugins/synced_folders/nfs/action_cleanup_test.rb b/test/unit/plugins/synced_folders/nfs/action_cleanup_test.rb index 9be10dd52..3fc329238 100644 --- a/test/unit/plugins/synced_folders/nfs/action_cleanup_test.rb +++ b/test/unit/plugins/synced_folders/nfs/action_cleanup_test.rb @@ -31,9 +31,18 @@ describe VagrantPlugins::SyncedFolderNFS::ActionCleanup do subject.call(env) end + it "does nothing if the host doesn't support pruning NFS" do + host.stub(:capability?).with(:nfs_prune).and_return(false) + host.should_receive(:capability).never + app.should_receive(:call).with(env) + + subject.call(env) + end + it "prunes the NFS entries if valid IDs are given" do env[:nfs_valid_ids] = [1,2,3] + host.stub(:capability?).with(:nfs_prune).and_return(true) host.should_receive(:capability).with(:nfs_prune, machine.ui, [1,2,3]).ordered app.should_receive(:call).with(env).ordered