4
4
5
5
require "vagrant/util/scoped_hash_override"
6
6
7
+ require "vagrant/util/which"
8
+
7
9
module VagrantPlugins
8
10
module AWS
9
11
module Action
@@ -28,13 +30,23 @@ def call(env)
28
30
# Ignore disabled shared folders
29
31
next if data [ :disabled ]
30
32
33
+ unless Vagrant ::Util ::Which . which ( 'rsync' )
34
+ env [ :ui ] . warn ( I18n . t ( 'vagrant_aws.rsync_not_found_warning' ) )
35
+ break
36
+ end
37
+
31
38
hostpath = File . expand_path ( data [ :hostpath ] , env [ :root_path ] )
32
39
guestpath = data [ :guestpath ]
33
40
34
41
# Make sure there is a trailing slash on the host path to
35
42
# avoid creating an additional directory with rsync
36
43
hostpath = "#{ hostpath } /" if hostpath !~ /\/ $/
37
44
45
+ # on windows rsync.exe requires cygdrive-style paths
46
+ if Vagrant ::Util ::Platform . windows?
47
+ hostpath = hostpath . gsub ( /^(\w ):/ ) { "/cygdrive/#{ $1} " }
48
+ end
49
+
38
50
env [ :ui ] . info ( I18n . t ( "vagrant_aws.rsync_folder" ,
39
51
:hostpath => hostpath ,
40
52
:guestpath => guestpath ) )
@@ -63,6 +75,12 @@ def call(env)
63
75
hostpath ,
64
76
"#{ ssh_info [ :username ] } @#{ ssh_info [ :host ] } :#{ guestpath } " ]
65
77
78
+ # we need to fix permissions when using rsync.exe on windows, see
79
+ # http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
80
+ if Vagrant ::Util ::Platform . windows?
81
+ command . insert ( 1 , "--chmod" , "ugo=rwX" )
82
+ end
83
+
66
84
r = Vagrant ::Util ::Subprocess . execute ( *command )
67
85
if r . exit_code != 0
68
86
raise Errors ::RsyncError ,
0 commit comments