core: Don't set index uuid file if data dir is nil

This commit is contained in:
Mitchell Hashimoto 2014-04-05 11:30:06 -07:00
parent 47b5a3fcdb
commit cddd878656
1 changed files with 7 additions and 3 deletions

View File

@ -121,7 +121,8 @@ module Vagrant
end end
# Keep track of where our UUID should be placed # Keep track of where our UUID should be placed
@index_uuid_file = @data_dir.join("index_uuid") @index_uuid_file = nil
@index_uuid_file = @data_dir.join("index_uuid") if @data_dir
# Initializes the provider last so that it has access to all the # Initializes the provider last so that it has access to all the
# state we setup on this machine. # state we setup on this machine.
@ -232,10 +233,12 @@ module Vagrant
@env.machine_index.release(entry) @env.machine_index.release(entry)
# Store our UUID so we can access it later # Store our UUID so we can access it later
if @index_uuid_file
@index_uuid_file.open("w+") do |f| @index_uuid_file.open("w+") do |f|
f.write(entry.id) f.write(entry.id)
end end
end end
end
else else
# Delete the file, since the machine is now destroyed # Delete the file, since the machine is now destroyed
id_file.delete if id_file.file? id_file.delete if id_file.file?
@ -271,6 +274,7 @@ module Vagrant
# #
# @return [String] UUID or nil if we don't have one yet. # @return [String] UUID or nil if we don't have one yet.
def index_uuid def index_uuid
return nil if !@index_uuid_file
return @index_uuid_file.read.chomp if @index_uuid_file.file? return @index_uuid_file.read.chomp if @index_uuid_file.file?
return nil return nil
end end