Close and unlink iso tempfile

On Windows tempfile.delete does not delete the file. It needs
to be closed and unlinked
This commit is contained in:
sophia 2020-07-28 09:52:59 -05:00
parent 5caae15f22
commit 476977a732
2 changed files with 4 additions and 2 deletions

View File

@ -30,7 +30,8 @@ module Vagrant
if file_destination.nil?
tmpfile = Tempfile.new(["vagrant", ".iso"])
file_destination = Pathname.new(tmpfile.path)
tmpfile.delete
tmpfile.close
tmpfile.unlink
else
file_destination = Pathname.new(file_destination.to_s)
# If the file destination path is a folder, target the output to a randomly named

View File

@ -62,7 +62,8 @@ describe VagrantPlugins::HostDarwin::Cap::FsISO do
).and_return(double(exit_code: 0))
# Should create a directory wherever Tempfile creates files by default
expect(FileUtils).to receive(:mkdir_p).with(Pathname.new(file_destination).dirname)
allow(file_destination).to receive(:close)
allow(file_destination).to receive(:unlink)
output = subject.create_iso(env, "/foo/src")
expect(output.to_s).to eq(file_destination)
end