diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 919e40c2..3dcc6932 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -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 diff --git a/app/helpers/dmsf_zip.rb b/app/helpers/dmsf_zip.rb index e09e4eda..ef406fad 100644 --- a/app/helpers/dmsf_zip.rb +++ b/app/helpers/dmsf_zip.rb @@ -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 \ No newline at end of file