mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 21:26:07 +10:00
Use Tempfile.open for automatic cleanup
This commit is contained in:
+1
-6
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user