From 1c50646677ea1fcd2b7c238c0e94715a1349dada Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 11 Nov 2014 11:39:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8C=85=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=96=87=E4=BB=B6=E5=90=8D=E4=B8=BA=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E8=AF=A5=E4=BD=9C=E4=B8=9A=E7=9A=84=E5=AD=A6=E7=94=9F=E5=A7=93?= =?UTF-8?q?=E5=90=8D=5F=E5=AD=A6=E7=94=9F=E5=AD=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index b2195adc3..10c42cd6c 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -72,7 +72,7 @@ class ZipdownController < ApplicationController homeattach.attachments.each do |attach| homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end - zipping("#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) + zipping("#{homeattach.user.name}_#{homeattach.user.user_extensions.student_id}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) end @@ -81,14 +81,14 @@ class ZipdownController < ApplicationController ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') input_filename = files_paths - rename_zipfile = zip_name_refer ||= "archive_#{Time.now.to_i}.zip" + rename_zipfile = zip_name_refer ||= "homework.zip" zipfile_name = "#{output_path}/#{rename_zipfile}" Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| input_filename.each do |filename| - rename_file = Time.now.to_i.to_s+ ic.iconv( (File.basename(filename)) ).to_s + rename_file = ic.iconv( (File.basename(filename)) ).to_s rename_file = ic.iconv( filename_to_real( File.basename(filename))).to_s if is_attachment zipfile.add(rename_file, filename)