@@ -19,11 +19,13 @@ def update_guest(machine)
19
19
# download and modify file with Vagrant-managed entries
20
20
file = @global_env . tmp_path . join ( "hosts.#{ machine . name } " )
21
21
machine . communicate . download ( realhostfile , file )
22
- update_file ( file , machine , false )
22
+ if update_file ( file , machine , false )
23
+
24
+ # upload modified file and remove temporary file
25
+ machine . communicate . upload ( file , '/tmp/hosts' )
26
+ machine . communicate . sudo ( "#{ move_cmd } /tmp/hosts #{ realhostfile } " )
27
+ end
23
28
24
- # upload modified file and remove temporary file
25
- machine . communicate . upload ( file , '/tmp/hosts' )
26
- machine . communicate . sudo ( "#{ move_cmd } /tmp/hosts #{ realhostfile } " )
27
29
# i have no idea if this is a windows competibility issue or not, but sometimes it dosen't work on my machine
28
30
begin
29
31
FileUtils . rm ( file )
@@ -49,16 +51,19 @@ class << self
49
51
end
50
52
51
53
FileUtils . cp ( hosts_location , file )
52
- update_file ( file )
53
- copy_proc . call
54
+ if update_file ( file )
55
+ copy_proc . call
56
+ end
54
57
end
55
58
56
59
private
57
60
58
61
def update_file ( file , resolving_machine = nil , include_id = true )
59
62
file = Pathname . new ( file )
60
- new_file_content = update_content ( file . read , resolving_machine , include_id )
63
+ old_file_content = file . read
64
+ new_file_content = update_content ( old_file_content , resolving_machine , include_id )
61
65
file . open ( 'w' ) { |io | io . write ( new_file_content ) }
66
+ old_file_content != new_file_content
62
67
end
63
68
64
69
def update_content ( file_content , resolving_machine , include_id )
0 commit comments