whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Detect concatenation failure
Date Tue, 23 Oct 2018 17:35:25 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 005c60e  Detect concatenation failure
005c60e is described below

commit 005c60e938132260d9e408fbd1f12cc8dbee0ca3
Author: Sebb <sebb@apache.org>
AuthorDate: Tue Oct 23 18:35:11 2018 +0100

    Detect concatenation failure
---
 www/secretary/workbench/views/actions/drop.json.rb | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/www/secretary/workbench/views/actions/drop.json.rb b/www/secretary/workbench/views/actions/drop.json.rb
index e0218fd..b9f67e3 100644
--- a/www/secretary/workbench/views/actions/drop.json.rb
+++ b/www/secretary/workbench/views/actions/drop.json.rb
@@ -8,18 +8,24 @@ begin
   source = message.find(@source).as_pdf
   target = message.find(@target).as_pdf
 
-  output = SafeTempFile.new('output')
+  output = SafeTempFile.new('output') # N.B. this is created as binary
 
   Kernel.system 'pdftk', target.path, source.path, 'cat', 'output',
     output.path
 
   name = @target.sub(/\.\w+$/, '') + '.pdf'
 
+  # If output file is empty, then the command failed
+  raise "Failed to concatenate #{@target} and #{@source}" unless File.size? output
+
   message.update_attachment @target, content: output.read, name: name,
     mime: 'application/pdf'
 
   message.delete_attachment @source
 
+rescue
+  Wunderbar.error "Failed to concatenate #{@target} and #{@source}"
+  raise
 ensure
   source.unlink if source
   target.unlink if target


Mime
View raw message