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 d13a6b1  Overlooked setting content-type
d13a6b1 is described below

commit d13a6b1628e70cde17caa8ddbd805be61ebabe5f
Author: Sebb <[email protected]>
AuthorDate: Thu Jul 23 17:21:57 2020 +0100

    Overlooked setting content-type
---
 www/secretary/workbench/models/message.rb | 11 +++++------
 www/secretary/workbench/tasks.rb          |  9 ++++++---
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/www/secretary/workbench/models/message.rb 
b/www/secretary/workbench/models/message.rb
index 49af9ed..eccf9d6 100644
--- a/www/secretary/workbench/models/message.rb
+++ b/www/secretary/workbench/models/message.rb
@@ -206,23 +206,22 @@ class Message
   # 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]]
+  # [[name, open temp file, content-type]]
   def write_att(*attachments)
     files = []
 
     # drop all nil and empty values
     attachments = attachments.flatten.reject {|name| name.to_s.empty?}
 
-    # if last argument is a Hash, treat it as name/value pairs
-    attachments += attachments.pop.to_a if Hash === attachments.last
-
     if attachments.flatten.length == 1
       attachment = attachments.first
-      files << [attachment, find(attachment).as_file]
+      att = find(attachment)
+      files << [attachment, att.as_file, att.content_type.untaint]
     else
       # write out selected attachment
       attachments.each do |attachment, basename|
-        files << [attachment, find(attachment).as_file]
+        att = find(attachment)
+        files << [attachment, att.as_file, att.content_type.untaint]
       end
     end
     files
diff --git a/www/secretary/workbench/tasks.rb b/www/secretary/workbench/tasks.rb
index 0d519d4..a53bfdb 100644
--- a/www/secretary/workbench/tasks.rb
+++ b/www/secretary/workbench/tasks.rb
@@ -103,7 +103,7 @@ class Wunderbar::JsonBuilder
         end
         container = ASF::SVN.svnpath!(docdir, outfilename)
         extras << ['mkdir', container]
-        dest.each do |name, file|
+        dest.each do |name, file, content_type|
           if docdir == 'iclas' && outfileext # special processing for output 
name
             if name == docname
               name = "icla%s" % outfileext
@@ -113,17 +113,20 @@ class Wunderbar::JsonBuilder
               Wunderbar.warn "Cannot recognise #{name} as #{docname} or 
#{docsig}"
             end
           end
+          outpath = File.join(container, name)
           # N.B. file cannot exist here, because the directory was created as 
part of the same commit
-          extras << ['put', file.path, File.join(container, name)]
+          extras << ['put', file.path, outpath]
+          extras << ['propset', 'svn:mime-type', content_type, outpath]
         end
       else
-        name, file = dest.flatten
+        name, file, content_type = dest.flatten
         outpath = ASF::SVN.svnpath!(docdir,"#{outfilename}#{outfileext}")
         # TODO does it matter that the revision is not known?
         if ASF::SVN.exist?(outpath, nil, env)
           raise IOError.new("#{outpath} already exists!")
         else
           extras << ['put', file.path, outpath]
+          extras << ['propset', 'svn:mime-type', content_type, outpath]
         end
       end
 

Reply via email to