This commit is contained in:
Stanislav German-Evtushenko 2026-04-11 02:54:00 +09:00 committed by GitHub
commit 64a513f409
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -21,6 +21,11 @@ module VagrantPlugins
@@logger.debug("Mounting #{name} (#{options[:hostpath]} to #{guestpath})")
if mounted?(machine, guest_path)
@@logger.info("Skipping mount: #{guest_path} is already mounted")
return
end
builtin_mount_type = "-cit #{mount_type}"
addon_mount_type = "-t #{mount_type}"
@ -72,6 +77,10 @@ module VagrantPlugins
machine.communicate.sudo("rmdir #{guest_path}", error_check: false)
end
end
def self.mounted?(machine, guest_path)
machine.communicate.test("mountpoint -q #{guest_path}")
end
end
end
end

View file

@ -94,6 +94,16 @@ EOF
cap.mount_virtualbox_shared_folder(machine, mount_name, mount_guest_path, folder_options)
end
end
context "already mounted" do
it "skips mounting if already mounted" do
expect(folder_plugin).to receive(:capability).with(:mount_type).and_return("vboxsf")
expect(comm).to receive(:test).with("mountpoint -q #{mount_guest_path}").and_return(true)
expect(comm).not_to receive(:sudo).with(/mount/)
cap.mount_virtualbox_shared_folder(machine, mount_name, mount_guest_path, folder_options)
end
end
end
describe ".unmount_virtualbox_shared_folder" do