Sha256: 0d4786c77bf7099220913f18ed93998cf8803420a2a448e0fc47b54d76f0a01a
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require "fileutils" module VagrantPlugins module ProviderVirtualBox module Action # Cleans up the VirtualBox machine folder for any ".xml-prev" # files which VirtualBox may have left over. This is a bug in # VirtualBox. As soon as this is fixed, this middleware can and # will be removed. class CleanMachineFolder def initialize(app, env) @app = app end def call(env) clean_machine_folder(env[:machine].provider.driver.read_machine_folder) @app.call(env) end def clean_machine_folder(machine_folder) folder = File.join(machine_folder, "*") # Small safeguard against potentially unwanted rm-rf, since the default # machine folder will typically always be greater than 10 characters long. # For users with it < 10, out of luck? return if folder.length < 10 Dir[folder].each do |f| next unless File.directory?(f) keep = Dir["#{f}/**/*"].find do |d| # Find a file that doesn't have ".xml-prev" as the suffix, # which signals that we want to keep this folder File.file?(d) && !(File.basename(d) =~ /\.vbox-prev$/) end FileUtils.rm_rf(f) if !keep end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-cloudstack-1.2.0 | vendor/bundle/bundler/gems/vagrant-c84e05fd063f/plugins/providers/virtualbox/action/clean_machine_folder.rb |