Skip to content

Commit

Permalink
Use Tempfile.open for automatic cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobvosmaer committed Jul 17, 2013
1 parent 3ada8f4 commit 656d800
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions app/models/key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,10 @@ def shell_id
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?
Expand Down

0 comments on commit 656d800

Please sign in to comment.