Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2013-07-02 16:00:21 +0400
committerJacob Vosmaer <contact@jacobvosmaer.nl>2013-07-17 17:17:18 +0400
commit656d800f8c72bc6bb97700b7289a2d5eebc4e42f (patch)
treefc81e1fb40d91f0ca8a0665a3915794f8c229daf /app/models/key.rb
parent3ada8f45c7a719a95864b3ee2c1acdfdf4468eaa (diff)
Use Tempfile.open for automatic cleanup
Diffstat (limited to 'app/models/key.rb')
-rw-r--r--app/models/key.rb7
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?