Commit 656d800f authored by Jacob Vosmaer's avatar Jacob Vosmaer

Use Tempfile.open for automatic cleanup

parent 3ada8f45
......@@ -56,15 +56,10 @@ class Key < ActiveRecord::Base
def generate_fingerpint
cmd_status = 0
cmd_output = ''
file = Tempfile.new('gitlab_key_file')
begin
Tempfile.open('gitlab_key_file') do |file|
file.puts key
file.rewind
cmd_output, cmd_status = popen("ssh-keygen -lf #{file.path}", '/tmp')
ensure
file.close
file.unlink # deletes the temp file
end
if cmd_status.zero?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment