From 477f4801751dbb6e863606f5e5971e7b0da0045a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 10 Jan 2015 16:06:33 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0EXCEL=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84gem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 634af9683..498a4fca6 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,8 @@ gem "coderay", "~> 1.0.6" gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "builder", "3.0.0" gem 'acts-as-taggable-on', '2.4.1' +gem 'spreadsheet' +gem 'ruby-ole' group :development do gem 'better_errors', path: 'lib/better_errors' From 41679a8d5c04463883174f3ace0d158d30b317f0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 10 Jan 2015 16:20:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=E6=97=B6=E7=9A=84=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d6e7815f9..36c26625e 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2239,5 +2239,5 @@ zh: label_course_prompt: 课程: label_contain_resource: 已包含资源: label_quote_resource_failed: ",此资源引用失败! " - label_file_lost: 以下文件在服务器丢失,请联系相关人员重新上传: + label_file_lost: 以下无法成功下载,请联系相关人员重新上传: From bf7eaa7a8084f76c0189f8f0279b1528161970d8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 10 Jan 2015 17:41:50 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=AD=A6=E7=94=9F=E6=8F=90=E4=BA=A4=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=E5=90=8E=EF=BC=8C=E6=89=93=E5=8C=85?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=BC=82=E5=B8=B8=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 12 +++++++++++- config/locales/zh.yml | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index ac8a74379..b329e4c27 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -101,10 +101,20 @@ class ZipdownController < ApplicationController Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| input_filename.each do |filename| + flag = true + index = 1 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) + begin + zipfile.add(rename_file, filename) + flag = false + rescue Exception => e + zipfile.get_output_stream('FILE_NOTICE.txt') do |os| + os.write l(:label_file_exist) + end + next + end end unless not_exist_file.empty? zipfile.get_output_stream('FILE_LOST.txt') do |os| diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 36c26625e..568a60cac 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2240,4 +2240,5 @@ zh: label_contain_resource: 已包含资源: label_quote_resource_failed: ",此资源引用失败! " label_file_lost: 以下无法成功下载,请联系相关人员重新上传: + label_file_exist: 该作品中有重复命名文件,请通过文件名学号和姓名信息进入该作业详细界面手动下载