Overlooked setting content-type
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 @@
# 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 @@
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 @@
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