|
|
@ -314,6 +314,7 @@ module ZipService
|
|
|
|
rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip"
|
|
|
|
rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip"
|
|
|
|
# 文件名过长
|
|
|
|
# 文件名过长
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index = 1
|
|
|
|
if rename_zipfile.size > MAX_PATH
|
|
|
|
if rename_zipfile.size > MAX_PATH
|
|
|
|
rename_zipfile = rename_zipfile[0,rename_zipfile.size-4][0,MAX_PATH-4] + rename_zipfile[-4,4]
|
|
|
|
rename_zipfile = rename_zipfile[0,rename_zipfile.size-4][0,MAX_PATH-4] + rename_zipfile[-4,4]
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -329,7 +330,10 @@ module ZipService
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
zipfile.add(rename_file, filename)
|
|
|
|
zipfile.add(rename_file, filename)
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
|
zipfile.get_output_stream('FILE_NOTICE.txt'){|os| os.write l(:label_file_exist)}
|
|
|
|
rename_file = rename_same_file(rename_file, index)
|
|
|
|
|
|
|
|
index += 1
|
|
|
|
|
|
|
|
zipfile.add(rename_file, filename)
|
|
|
|
|
|
|
|
# zipfile.get_output_stream('FILE_NOTICE.txt'){|os| os.write l(:label_file_exist)}
|
|
|
|
next
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -376,4 +380,11 @@ module ZipService
|
|
|
|
attach = Attachment.find_by_disk_filename(name)
|
|
|
|
attach = Attachment.find_by_disk_filename(name)
|
|
|
|
attach.filename
|
|
|
|
attach.filename
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def rename_same_file(name, index)
|
|
|
|
|
|
|
|
basename = File.basename(name, ".*")
|
|
|
|
|
|
|
|
new_basename = basename + "_" + index.to_s
|
|
|
|
|
|
|
|
extname = File.extname(name)
|
|
|
|
|
|
|
|
new_basename + extname
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|