Skip to content

Commit c3706d2

Browse files
committed
Added begin/ensure/end
1 parent e57c57e commit c3706d2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/grim/image_magick_processor.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ def save(pdf, index, path, options)
3939
command << "-density #{density}"
4040
command << "#{Shellwords.shellescape(pdf.path)}[#{index}]"
4141
command << path
42-
43-
ENV['PATH'] = "#{File.dirname(@ghostscript_path)}#{File::PATH_SEPARATOR}#{ENV['PATH']}" if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
44-
45-
result = `#{command.join(' ')}`
4642

47-
ENV['PATH'] = @original_path if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
43+
begin
44+
ENV['PATH'] = "#{File.dirname(@ghostscript_path)}#{File::PATH_SEPARATOR}#{ENV['PATH']}" if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
45+
result = `#{command.join(' ')}`
46+
ensure
47+
ENV['PATH'] = @original_path if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
48+
end
4849

4950
$? == 0 || raise(UnprocessablePage, result)
51+
5052
end
5153
end
5254
end

0 commit comments

Comments
 (0)