Ensure temporary files are retained
diff --git a/www/secretary/workbench/models/attachment.rb b/www/secretary/workbench/models/attachment.rb
index afded69..9daf050 100644
--- a/www/secretary/workbench/models/attachment.rb
+++ b/www/secretary/workbench/models/attachment.rb
@@ -44,6 +44,9 @@
     name.untaint
   end
 
+  # Returns the attachment as an open temporary file
+  # Warning: if the reference count goes to 0, the file may be deleted
+  # so calling code must retain the reference until done.
   def as_file
     file = SafeTempFile.new([safe_name, '.pdf'])
     file.write(body)
diff --git a/www/secretary/workbench/models/message.rb b/www/secretary/workbench/models/message.rb
index 0ff58f8..49af9ed 100644
--- a/www/secretary/workbench/models/message.rb
+++ b/www/secretary/workbench/models/message.rb
@@ -203,8 +203,10 @@
 
   #
   # write one or more attachments
-  # returns list of temporary file names
-  # [[name, path]]
+  # returns list of input names with their temporary file pointers
+  # It's not safe to return the path names of the temp files as
+  # that allows the files to be deleted by garbage collection
+  # [[name, open temp file]]
   def write_att(*attachments)
     files = []
 
@@ -216,11 +218,11 @@
 
     if attachments.flatten.length == 1
       attachment = attachments.first
-      files << [attachment, find(attachment).as_file.path]
+      files << [attachment, find(attachment).as_file]
     else
       # write out selected attachment
       attachments.each do |attachment, basename|
-        files << [attachment, find(attachment).as_file.path]
+        files << [attachment, find(attachment).as_file]
       end
     end
     files
diff --git a/www/secretary/workbench/tasks.rb b/www/secretary/workbench/tasks.rb
index cba6bd1..209c45d 100644
--- a/www/secretary/workbench/tasks.rb
+++ b/www/secretary/workbench/tasks.rb
@@ -103,12 +103,12 @@
         end
         container = ASF::SVN.svnpath!(docdir, outfilename)
         extras << ['mkdir', container]
-        dest.each do |name, path|
-          extras << ['put', path, File.join(container, name)]
+        dest.each do |name, file|
+          extras << ['put', file.path, File.join(container, name)]
         end
       else
-        name, path = dest.flatten
-        extras << ['put', path, ASF::SVN.svnpath!(docdir,"#{outfilename}#{outfileext}")]
+        name, file = dest.flatten
+        extras << ['put', file.path, ASF::SVN.svnpath!(docdir,"#{outfilename}#{outfileext}")]
       end
 
       text = yield text # update the index