Skip to content

Commit

Permalink
Work around the removal of Dir::Tmpname#make_tmpname (bsc#1162221)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzejrou committed Jan 30, 2020
1 parent 0e87543 commit 4d08c0c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hawk/app/controllers/graphs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def show
respond_to do |format|
format.html
format.svg do
path = Pathname.new("#{Rails.root}/tmp").join(Dir::Tmpname.make_tmpname(["graph", ".svg"], nil))
path = Pathname.new("#{Rails.root}/tmp").join(make_tmpname("graph", ".svg"))
begin
_out, err, rc = Invoker.instance.no_log do |invoker|
invoker.crm("configure", "graph", "dot", path.to_s, "svg")
Expand Down Expand Up @@ -52,4 +52,12 @@ def set_title
def set_cib
@cib = current_cib
end

private

def make_tmpname(prefix, suffix)
timestamp = Time.now.strftime("%Y%m%d")
random = rand(0x100000000).to_s(36)
"#{prefix}#{timestamp}-#{$$}-#{random}#{suffix}"
end
end

0 comments on commit 4d08c0c

Please sign in to comment.