Skip to content

Commit

Permalink
Merge pull request #386 from Parallels/fix-mount-name-cap
Browse files Browse the repository at this point in the history
[cap/mount_options] Fix "mount_name" compatibility with Vagrant 2.2.15+
  • Loading branch information
legal90 authored Apr 14, 2021
2 parents 43c1d7f + a7cffc2 commit 44ab663
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions lib/vagrant-parallels/cap/mount_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ def self.mount_type(machine)
return PRL_MOUNT_TYPE
end

def self.mount_name(machine, data)
data[:guestpath].gsub(/[*":<>?|\/\\]/,'_').sub(/^_/, '')
## We have to support 2 different expected interfaces of `mount_name` call:
## Vagrant < 2.2.15: `def self.mount_name(machine, data)`
## Vagrant >= 2.2.15: `def self.mount_name(machine, id, data)`
## https://github.com/Parallels/vagrant-parallels/issues/384
def self.mount_name(*args)
if args.length >= 3
id = args[1]
else
id = args[-1][:guestpath]
end

id.gsub(/[*":<>?|\/\\]/,'_').sub(/^_/, '')
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/vagrant-parallels/synced_folder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def enable(machine, folders, _opts)
end

defs << {
name: data[:plugin].capability(:mount_name, data),
name: data[:plugin].capability(:mount_name, id, data),
hostpath: hostpath.to_s,
}
end
Expand Down Expand Up @@ -62,7 +62,7 @@ def enable(machine, folders, _opts)
# Mount the actual folder
machine.guest.capability(
:mount_parallels_shared_folder,
data[:plugin].capability(:mount_name, data),
data[:plugin].capability(:mount_name, id, data),
data[:guestpath],
data
)
Expand All @@ -84,7 +84,7 @@ def disable(machine, folders, _opts)
end

# Remove the shared folders from the VM metadata
names = folders.map { |_id, data| data[:plugin].capability(:mount_name, data) }
names = folders.map { |id, data| data[:plugin].capability(:mount_name, id, data) }
driver(machine).unshare_folders(names)
end

Expand Down

0 comments on commit 44ab663

Please sign in to comment.