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
Loading
@@ -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?
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