diff --git a/app/helpers/dmsf_helper.rb b/app/helpers/dmsf_helper.rb index eccfc89a..83119e7a 100644 --- a/app/helpers/dmsf_helper.rb +++ b/app/helpers/dmsf_helper.rb @@ -35,19 +35,10 @@ module DmsfHelper end - def self.temp_dir - if Setting.plugin_redmine_dmsf['dmsf_tmpdir'].present? - tmpdir = Pathname.new(Setting.plugin_redmine_dmsf['dmsf_tmpdir']) - else - tmpdir = Pathname.new(Dir.tmpdir) - end - tmpdir - end - def self.temp_filename(filename) filename = sanitize_filename(filename) timestamp = DateTime.current.strftime('%y%m%d%H%M%S') - while temp_dir.join("#{timestamp}_#{filename}").exist? + while File.exist?(File.join(Rails.root, 'tmp', "#{timestamp}_#{filename}")) timestamp.succ! end "#{timestamp}_#{filename}" diff --git a/app/models/dmsf_upload.rb b/app/models/dmsf_upload.rb index 34f86c24..fb463a81 100644 --- a/app/models/dmsf_upload.rb +++ b/app/models/dmsf_upload.rb @@ -39,7 +39,7 @@ class DmsfUpload attr_accessor :digest def disk_file - DmsfHelper.temp_dir.join(disk_filename).to_s + File.join Rails.root, 'tmp', disk_filename end def self.create_from_uploaded_attachment(project, folder, uploaded_file) diff --git a/app/views/settings/_dmsf_settings.html.erb b/app/views/settings/_dmsf_settings.html.erb index 0ea98586..9002e5a5 100644 --- a/app/views/settings/_dmsf_settings.html.erb +++ b/app/views/settings/_dmsf_settings.html.erb @@ -80,36 +80,6 @@ <% end %> <% end %> -

- <%= content_tag(:label, l(:label_tmpdir)) %> - <% - tmpdir = @settings['dmsf_tmpdir'].strip if @settings['dmsf_tmpdir'].present? - tmpdir = Dir.tmpdir if tmpdir.blank? - %> - <%= text_field_tag 'settings[dmsf_tmpdir]', tmpdir, size: 256 %> - - <%= l(:label_default) %>: <%= Dir.tmpdir %> - -

-<% unless File.exist?(tmpdir) %> - <% begin %> - <% FileUtils.mkdir_p tmpdir %> - <% rescue %> -

<%= l(:error_file_tmpdir_does_not_exist) %>

- <% end %> -<% end %> -<% path = Pathname.new(tmpdir) %> -<% testfilename = path.join('test.test') %> -<% if File.exist?(tmpdir) %> - <% begin %> - <% File.open(testfilename, 'wb') {} %> - <% rescue %> -

<%= l(:error_tmpfile_can_not_be_created) %>

- <% ensure %> - <% FileUtils.rm_f testfilename %> - <% end %> -<% end %> -

<%= content_tag :label, l(:label_dmsf_office_bin) %> <%= text_field_tag 'settings[office_bin]', @settings['office_bin'], size: 10 %> diff --git a/config/locales/cs.yml b/config/locales/cs.yml index be7f74d1..d9a08b03 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -378,10 +378,6 @@ cs: label_dmsf_attachments: DMS přílohy label_basic_attachments: Souborové přílohy - label_tmpdir: Adresář pro dočasné soubory - error_file_tmpdir_does_not_exist: Adresář pro dočasné soubory neexistuje a nemůže být vytvořen - error_tmpfile_can_not_be_created: Nelze vytvořit soubor v adresáři pro dočasné soubory - label_email_from_override: Od text_email_from_override: aktuálně přihlášený uživatel label_email_reply_to: Odpovědět komu diff --git a/config/locales/de.yml b/config/locales/de.yml index be89b442..b28f7cb3 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -374,10 +374,6 @@ de: label_dmsf_attachments: DMS Anhänge label_basic_attachments: Dateianhänge - label_tmpdir: Temporärer Dateipfad - error_file_tmpdir_does_not_exist: "Temporärer Dateipfad existiert nicht und kann nicht erstellt werden." - error_tmpfile_can_not_be_created: "Dateien können nicht im temporären Dateipfad erstellt werden." - label_email_from_override: Von text_email_from_override: Der angemeldete Benutzer label_email_reply_to: Antwort an diff --git a/config/locales/en.yml b/config/locales/en.yml index 5920c927..99d1e727 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -378,10 +378,6 @@ en: label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/es.yml b/config/locales/es.yml index 7a3f4382..41e46e28 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -378,10 +378,6 @@ es: label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/fr.yml b/config/locales/fr.yml index a5ddb67b..f904ad7e 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -378,10 +378,6 @@ fr: label_dmsf_attachments: Pièces-jointes DMS label_basic_attachments: Pièces-jointes standards - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 7f6947f6..3f7c1cbd 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -377,10 +377,6 @@ hu: label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/it.yml b/config/locales/it.yml index 0b38b547..2da610f6 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -378,10 +378,6 @@ it: # Italian strings thx 2 Matteo Arceci! label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 4bc00366..4ec740d0 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -378,10 +378,6 @@ ja: label_dmsf_attachments: DMS 添付ファイル label_basic_attachments: 標準 添付ファイル - label_tmpdir: 一時フォルダのパス - error_file_tmpdir_does_not_exist: 指定された一時フォルダが存在せず、作成もできません - error_tmpfile_can_not_be_created: 指定された一時フォルダにファイルを作成できません - label_email_from_override: 差出人 text_email_from_override: 現在ログインしているユーザー label_email_reply_to: 返信先 diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 52a6c84f..5763d197 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -378,10 +378,6 @@ ko: label_dmsf_attachments: DMS 첨부 label_basic_attachments: 기본 첨부 - label_tmpdir: 임시 파일 경로 - error_file_tmpdir_does_not_exist: "임시 파일 경로가 존재하지 않거나 만들 수 없습니다" - error_tmpfile_can_not_be_created: "임시 파일 경로 디렉터리 내에 파일을 만들 수 없습니다" - label_email_from_override: 송신 text_email_from_override: 로그인한 사용자 label_email_reply_to: 회신 diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 50b91710..624ac0e8 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -378,10 +378,6 @@ nl: label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/pl.yml b/config/locales/pl.yml index e88ee576..d4cbc2aa 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -378,10 +378,6 @@ pl: label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 9cd6088a..88098f0b 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -378,10 +378,6 @@ pt-BR: label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 97ba539a..b4187ccc 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -378,10 +378,6 @@ sl: label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 5f242f2a..eb9b0c66 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -377,10 +377,6 @@ zh-TW: label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 3f6363cf..7eba0693 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -378,10 +378,6 @@ zh: label_dmsf_attachments: DMS Attachments label_basic_attachments: Basic Attachments - label_tmpdir: Temporary file path - error_file_tmpdir_does_not_exist: "Temporary file path doesn't exist and can't be created" - error_tmpfile_can_not_be_created: "Files can't be created in temporary file path directory" - label_email_from_override: From text_email_from_override: The user currently logged in label_email_reply_to: Reply-to diff --git a/init.rb b/init.rb index e2356d7d..fb04c4a3 100644 --- a/init.rb +++ b/init.rb @@ -53,7 +53,6 @@ Redmine::Plugin.register :redmine_dmsf do 'dmsf_webdav_disable_versioning' => '^\~\$|\.tmp$', 'dmsf_keep_documents_locked' => nil, 'dmsf_act_as_attachable' => nil, - 'dmsf_tmpdir' => Dir.tmpdir, 'dmsf_documents_email_from' => '', 'dmsf_documents_email_reply_to' => '', 'dmsf_documents_email_links_only' => nil, diff --git a/lib/redmine_dmsf/dmsf_zip.rb b/lib/redmine_dmsf/dmsf_zip.rb index f59d4033..bbc2663c 100644 --- a/lib/redmine_dmsf/dmsf_zip.rb +++ b/lib/redmine_dmsf/dmsf_zip.rb @@ -30,7 +30,7 @@ module RedmineDmsf attr_reader :files def initialize - @temp_file = Tempfile.new(%w(dmsf_zip_ .zip), DmsfHelper.temp_dir) + @temp_file = Tempfile.new(%w(dmsf_zip_ .zip), File.join(Rails.root, 'tmp')) @zip_file = ::Zip::OutputStream.open(@temp_file) @files = [] @folders = [] diff --git a/test/functional/dmsf_controller_test.rb b/test/functional/dmsf_controller_test.rb index b6fe3aa0..877e38ba 100644 --- a/test/functional/dmsf_controller_test.rb +++ b/test/functional/dmsf_controller_test.rb @@ -317,7 +317,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase end def test_entries_email - zip_file = Tempfile.new('test', DmsfHelper::temp_dir) + zip_file = Tempfile.new('test', File.join(Rails.root, 'tmp')) get :entries_email, params: { id: @project1, email: { to: 'to@test.com', from: 'from@test.com', subject: 'subject', body: 'body', expired_at: '2015-01-01', diff --git a/test/unit/dmsf_file_test.rb b/test/unit/dmsf_file_test.rb index a2fdaa7b..0058950d 100644 --- a/test/unit/dmsf_file_test.rb +++ b/test/unit/dmsf_file_test.rb @@ -232,9 +232,9 @@ class DmsfFileTest < RedmineDmsf::Test::UnitTest def test_findn_file_by_name assert DmsfFile.find_file_by_name(@project1, nil, 'test.txt') - assert_nil DmsfFile.find_file_by_name(@project1, nil, 'test.odt') + assert_nil DmsfFile.find_file_by_name(@project1, nil, 'test.ods') assert DmsfFile.find_file_by_name(@issue1, nil, 'test.pdf') - assert_nil DmsfFile.find_file_by_name(@issue1, nil, 'test.odt') + assert_nil DmsfFile.find_file_by_name(@issue1, nil, 'test.ods') end def test_storage_path diff --git a/test/unit/project_patch_test.rb b/test/unit/project_patch_test.rb index 433fdb10..fa8faf45 100644 --- a/test/unit/project_patch_test.rb +++ b/test/unit/project_patch_test.rb @@ -56,7 +56,7 @@ class ProjectPatchTest < RedmineDmsf::Test::UnitTest def test_dmsf_count User.current = @jsmith hash = @project1.dmsf_count - assert_equal 9, hash[:files] + assert_equal 10, hash[:files] assert_equal 5, hash[:folders] end @@ -70,7 +70,7 @@ class ProjectPatchTest < RedmineDmsf::Test::UnitTest def test_copy_dmsf User.current = @jsmith - assert_equal 4, @project1.dmsf_files.visible.all.size + assert_equal 5, @project1.dmsf_files.visible.all.size assert_equal 3, @project1.dmsf_folders.visible.all.size assert_equal 2, @project1.file_links.visible.all.size assert_equal 1, @project1.folder_links.visible.all.size @@ -84,7 +84,7 @@ class ProjectPatchTest < RedmineDmsf::Test::UnitTest @project3.copy_dmsf @project1 - assert_equal 5, @project3.dmsf_files.visible.all.size + assert_equal 6, @project3.dmsf_files.visible.all.size assert_equal 0, @project3.dmsf_folders.visible.all.size assert_equal 2, @project3.file_links.visible.all.size assert_equal 1, @project3.folder_links.visible.all.size