* fixed Issue 52: Proper Zipped content root
git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@144 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
parent
bf55a59c9a
commit
eb19bc0de2
@ -292,13 +292,13 @@ class DmsfController < ApplicationController
|
||||
if selected_folders && selected_folders.is_a?(Array)
|
||||
selected_folders.each do |selected_folder_id|
|
||||
check_project(folder = DmsfFolder.find(selected_folder_id))
|
||||
zip.add_folder(folder) unless folder.nil?
|
||||
zip.add_folder(folder, (@folder.dmsf_path_str unless @folder.nil?)) unless folder.nil?
|
||||
end
|
||||
end
|
||||
if selected_files && selected_files.is_a?(Array)
|
||||
selected_files.each do |selected_file_id|
|
||||
check_project(file = DmsfFile.find(selected_file_id))
|
||||
zip.add_file(file) unless file.nil?
|
||||
zip.add_file(file, (@folder.dmsf_path_str unless @folder.nil?)) unless file.nil?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -40,8 +40,9 @@ class DmsfZip
|
||||
@zip.close unless @zip.nil?
|
||||
end
|
||||
|
||||
def add_file(file)
|
||||
def add_file(file, root_path = nil)
|
||||
string_path = file.folder.nil? ? "" : file.folder.dmsf_path_str + "/"
|
||||
string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path
|
||||
string_path += file.name
|
||||
#TODO: somewhat ugly conversion problems handling bellow
|
||||
begin
|
||||
@ -58,16 +59,17 @@ class DmsfZip
|
||||
@file_count += 1
|
||||
end
|
||||
|
||||
def add_folder(folder)
|
||||
def add_folder(folder, root_path = nil)
|
||||
string_path = folder.dmsf_path_str + "/"
|
||||
string_path = string_path[(root_path.length + 1) .. string_path.length] if root_path
|
||||
#TODO: somewhat ugly conversion problems handling bellow
|
||||
begin
|
||||
string_path = Iconv.conv(Setting.plugin_redmine_dmsf["dmsf_zip_encoding"], "utf-8", string_path)
|
||||
rescue
|
||||
end
|
||||
@zip_file.put_next_entry(string_path)
|
||||
folder.subfolders.each { |subfolder| self.add_folder(subfolder) }
|
||||
folder.files.each { |file| self.add_file(file) }
|
||||
folder.subfolders.each { |subfolder| self.add_folder(subfolder, root_path) }
|
||||
folder.files.each { |file| self.add_file(file, root_path) }
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user