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 ...@@ -56,15 +56,10 @@ class Key < ActiveRecord::Base
def generate_fingerpint def generate_fingerpint
cmd_status = 0 cmd_status = 0
cmd_output = '' cmd_output = ''
file = Tempfile.new('gitlab_key_file') Tempfile.open('gitlab_key_file') do |file|
begin
file.puts key file.puts key
file.rewind file.rewind
cmd_output, cmd_status = popen("ssh-keygen -lf #{file.path}", '/tmp') cmd_output, cmd_status = popen("ssh-keygen -lf #{file.path}", '/tmp')
ensure
file.close
file.unlink # deletes the temp file
end end
if cmd_status.zero? 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