Skip to content
Snippets Groups Projects
Commit 656d800f authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

Use Tempfile.open for automatic cleanup

parent 3ada8f45
No related branches found
No related tags found
No related merge requests found
Loading
@@ -56,15 +56,10 @@ class Key < ActiveRecord::Base
Loading
@@ -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?
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment