From 390b20c100b4f7dbf994afae5e949c5a5b7435dd Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Thu, 10 Dec 2015 12:01:17 -0700 Subject: [PATCH] resolves #369 don't fail to delete tmp file --- lib/asciidoctor-pdf/converter.rb | 3 ++- lib/asciidoctor-pdf/temporary_path.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/asciidoctor-pdf/converter.rb b/lib/asciidoctor-pdf/converter.rb index 55db324c9..232263eef 100644 --- a/lib/asciidoctor-pdf/converter.rb +++ b/lib/asciidoctor-pdf/converter.rb @@ -2455,8 +2455,9 @@ def resolve_explicit_width attrs, max_width = bounds.width # QUESTION is there a better way to do this? # I suppose we could have @tmp_files as an instance variable on converter instead # It might be sufficient to delete temporary files once per conversion + # NOTE Ruby 1.9 will sometimes delete a tmp file before the process exits def unlink_tmp_file path - path.unlink if TemporaryPath === path + path.unlink if TemporaryPath === path && path.exist? end # QUESTION move to prawn/extensions.rb? diff --git a/lib/asciidoctor-pdf/temporary_path.rb b/lib/asciidoctor-pdf/temporary_path.rb index 3ee9c72cf..0ef6088df 100644 --- a/lib/asciidoctor-pdf/temporary_path.rb +++ b/lib/asciidoctor-pdf/temporary_path.rb @@ -4,6 +4,10 @@ module TemporaryPath def unlink ::File.unlink self end + + def exist? + ::File.file? self + end end end end