core: only set ID on machine if data dir [GH-3827]

This commit is contained in:
Mitchell Hashimoto 2014-05-17 11:40:40 -07:00
parent 5899227126
commit 5e9cef4efd
2 changed files with 15 additions and 8 deletions

View File

@ -6,6 +6,8 @@ IMPROVEMENTS:
BUG FIXES:
- commands/package: Package with `--base` for VirtualBox doesn't
crash. [GH-3827]
- provisioners/puppet: Fix setting facter vars with Windows
guests. [GH-3776]
- guests/freebsd: Properly register the rsync_pre capability

View File

@ -245,15 +245,20 @@ module Vagrant
def id=(value)
@logger.info("New machine ID: #{value.inspect}")
# The file that will store the id if we have one. This allows the
# ID to persist across Vagrant runs. Also, store the UUID for the
# machine index.
id_file = @data_dir.join("id")
id_file = nil
if @data_dir
# The file that will store the id if we have one. This allows the
# ID to persist across Vagrant runs. Also, store the UUID for the
# machine index.
id_file = @data_dir.join("id")
end
if value
# Write the "id" file with the id given.
id_file.open("w+") do |f|
f.write(value)
if id_file
# Write the "id" file with the id given.
id_file.open("w+") do |f|
f.write(value)
end
end
# If we don't have a UUID, then create one
@ -287,7 +292,7 @@ module Vagrant
end
else
# Delete the file, since the machine is now destroyed
id_file.delete if id_file.file?
id_file.delete if id_file && id_file.file?
# If we have a UUID associated with the index, remove it
uuid = index_uuid