Corrected some export file names (to have a slash between directory and file name)

This commit is contained in:
Alexey Verkhovsky 2005-04-08 05:29:20 +00:00
parent 6213e851e0
commit e3a48c2732

View file

@ -59,7 +59,7 @@ class WikiController < ApplicationController
def export_pdf def export_pdf
file_name = "#{@web.address}-tex-#{@web.revised_on.strftime('%Y-%m-%d-%H-%M-%S')}" file_name = "#{@web.address}-tex-#{@web.revised_on.strftime('%Y-%m-%d-%H-%M-%S')}"
file_path = @wiki.storage_path + file_name file_path = File.join(@wiki.storage_path, file_name)
export_web_to_tex "#{file_path}.tex" unless FileTest.exists? "#{file_path}.tex" export_web_to_tex "#{file_path}.tex" unless FileTest.exists? "#{file_path}.tex"
convert_tex_to_pdf "#{file_path}.tex" convert_tex_to_pdf "#{file_path}.tex"
@ -142,7 +142,7 @@ class WikiController < ApplicationController
page = wiki.read_page(@web_name, @page_name) page = wiki.read_page(@web_name, @page_name)
safe_page_name = @page.name.gsub(/\W/, '') safe_page_name = @page.name.gsub(/\W/, '')
file_name = "#{safe_page_name}-#{@web.address}-#{@page.created_at.strftime('%Y-%m-%d-%H-%M-%S')}" file_name = "#{safe_page_name}-#{@web.address}-#{@page.created_at.strftime('%Y-%m-%d-%H-%M-%S')}"
file_path = @wiki.storage_path + file_name file_path = File.join(@wiki.storage_path, file_name)
export_page_to_tex("#{file_path}.tex") unless FileTest.exists?("#{file_path}.tex") export_page_to_tex("#{file_path}.tex") unless FileTest.exists?("#{file_path}.tex")
# NB: this is _very_ slow # NB: this is _very_ slow
@ -249,7 +249,7 @@ class WikiController < ApplicationController
file_prefix = "#{@web.address}-#{file_type}-" file_prefix = "#{@web.address}-#{file_type}-"
timestamp = @web.revised_on.strftime('%Y-%m-%d-%H-%M-%S') timestamp = @web.revised_on.strftime('%Y-%m-%d-%H-%M-%S')
file_path = @wiki.storage_path + file_prefix + timestamp + '.zip' file_path = File.join(@wiki.storage_path, file_prefix + timestamp + '.zip')
tmp_path = "#{file_path}.tmp" tmp_path = "#{file_path}.tmp"
Zip::ZipOutputStream.open(tmp_path) do |zip_out| Zip::ZipOutputStream.open(tmp_path) do |zip_out|
@ -269,7 +269,7 @@ class WikiController < ApplicationController
EOL EOL
end end
end end
FileUtils.rm_rf(Dir[@wiki.storage_path + file_prefix + '*.zip']) FileUtils.rm_rf(Dir[File.join(@wiki.storage_path, file_prefix + '*.zip')])
FileUtils.mv(tmp_path, file_path) FileUtils.mv(tmp_path, file_path)
send_file file_path send_file file_path
end end