diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2013-07-02 14:00:21 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2013-07-17 15:17:18 +0200 |
commit | 656d800f8c72bc6bb97700b7289a2d5eebc4e42f (patch) | |
tree | fc81e1fb40d91f0ca8a0665a3915794f8c229daf | |
parent | 3ada8f45c7a719a95864b3ee2c1acdfdf4468eaa (diff) | |
download | gitlab-ce-656d800f8c72bc6bb97700b7289a2d5eebc4e42f.tar.gz |
Use Tempfile.open for automatic cleanup
-rw-r--r-- | app/models/key.rb | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/app/models/key.rb b/app/models/key.rb index 11c01242b15..f5fc141985e 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -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? |