From 28cc13ad387b6c809d2a474c8c7ebf85fe658d48 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 14 Oct 2011 18:20:10 +0200 Subject: [PATCH] Sort shared folders by length only if they have a guest path --- CHANGELOG.md | 3 ++- lib/vagrant/action/vm/share_folders.rb | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a396588e2..fe3f53d23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.8.8 (unreleased) - + - Mount shared folders shortest to longest to avoid mounting + subfolders first. [GH-525] ## 0.8.7 (September 13, 2011) diff --git a/lib/vagrant/action/vm/share_folders.rb b/lib/vagrant/action/vm/share_folders.rb index c4ce6cc14..04ec62120 100644 --- a/lib/vagrant/action/vm/share_folders.rb +++ b/lib/vagrant/action/vm/share_folders.rb @@ -52,7 +52,17 @@ module Vagrant @env["vm"].ssh.execute do |ssh| # short guestpaths first, so we don't step on ourselves - shared_folders.sort_by {|name, data| data[:guestpath].length}.each do |name, data| + folders = shared_folders.sort_by do |name, data| + if data[:guestpath] + data[:guestpath].length + else + # A long enough path to just do this at the end. + 10000 + end + end + + # Go through each folder and mount + folders.each do |name, data| if data[:guestpath] # Guest path specified, so mount the folder to specified point @env.ui.info(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",