From 860d39f9bdab0cc60c2ebcc24714e2189e73bb3e Mon Sep 17 00:00:00 2001
From: Karel Picman
<%= l(:error_file_storage_directory_does_not_exist) %>
+<%= l(:error_file_storage_directory_does_not_exist) %>
<% end %> <% end %> <% testfilename = DmsfFile.storage_path.join('test.test') %> @@ -88,6 +88,37 @@ <% 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') do |file| %> + <% end %> + <% rescue %> +<%= l(:error_tmpfile_can_not_be_created) %>
+ <% ensure %> + <% File.delete(testfilename) if File.exist?(testfilename) %> + <% end %> +<% end %> +<%= content_tag(:label, l(:label_physical_file_delete)) %> <%= check_box_tag('settings[dmsf_really_delete_files]', true, @settings['dmsf_really_delete_files']) %> diff --git a/config/locales/cs.yml b/config/locales/cs.yml index e2db6195..7efb3c9e 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -362,6 +362,10 @@ cs: label_caching_enabled: Povolit použití vyrovnávací paměti note_webdav_cahing_enabled: Odpovědi na požadavek PROPFIND jsou ukládány do vyrovnávací paměti za účelem zrychlení WebDAV komunikace. + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/de.yml b/config/locales/de.yml index 7d3e10fb..4817514e 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -359,6 +359,10 @@ de: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/en.yml b/config/locales/en.yml index ba013a40..0f3b8d1b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -170,7 +170,7 @@ en: label_number_of_folders: Folders label_number_of_documents: Documents error_file_storage_directory_does_not_exist: "File storage directory doesn't exist and can't be created" - error_file_can_not_be_created: "File can't be created in storage directory" + error_file_can_not_be_created: "Files can't be created in storage directory" error_wrong_zip_encoding: Wrong Zip encoding warning_xapian_not_available: Xapian not available menu_dmsf: DMS # Project tab title @@ -362,6 +362,10 @@ en: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/es.yml b/config/locales/es.yml index 79913d15..6902e514 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -362,6 +362,10 @@ es: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 29564e74..a733a5eb 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -362,6 +362,10 @@ fr: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 9272e6e3..638b9cbb 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -362,6 +362,10 @@ hu: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/it.yml b/config/locales/it.yml index d0a31f70..e85a0db4 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -362,6 +362,10 @@ it: # Italian strings thx 2 Matteo Arceci! label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/ja.yml b/config/locales/ja.yml index a4ca17ae..b1aab635 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -362,6 +362,10 @@ ja: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/pl.yml b/config/locales/pl.yml index bea61604..2a6a289d 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -362,6 +362,10 @@ pl: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index fd34e75b..b7456fa9 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -362,6 +362,10 @@ pt-BR: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 96088e75..f566c5af 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -362,6 +362,10 @@ ru: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 88422ca9..b16fcc49 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -362,6 +362,10 @@ sl: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index fbcce82f..3a961980 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -362,6 +362,10 @@ zh-TW: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 7519c5dc..30599ae1 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -362,6 +362,10 @@ zh: label_caching_enabled: Caching enabled note_webdav_cahing_enabled: PROPFIND responses are cached in order to speed up WebDAV communication + 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" + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/init.rb b/init.rb index cac92460..a5701848 100644 --- a/init.rb +++ b/init.rb @@ -55,7 +55,8 @@ Redmine::Plugin.register :redmine_dmsf do 'dmsf_keep_documents_locked' => false, 'dmsf_act_as_attachable' => false, 'dmsf_show_system_folders' => false, - 'dmsf_webdav_caching_enabled' => false + 'dmsf_webdav_caching_enabled' => false, + 'dmsf_tmpdir' => Dir.tmpdir } # Uncomment to remove the original Documents from searching (replaced with DMSF) diff --git a/test/integration/rest_api/dmsf_file_api_test.rb b/test/integration/rest_api/dmsf_file_api_test.rb index d53f2819..45535e91 100644 --- a/test/integration/rest_api/dmsf_file_api_test.rb +++ b/test/integration/rest_api/dmsf_file_api_test.rb @@ -77,7 +77,7 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest def test_upload_document timestamp = DateTime.now.strftime('%y%m%d%H%M') - Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path("./dmsf_test-#{timestamp}", DmsfHelper.temp_dir) + Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = DmsfHelper.temp_dir.join("dmsf_test-#{timestamp}").to_s FileUtils.mkdir_p(Setting.plugin_redmine_dmsf['dmsf_storage_directory']) @role.add_permission! :file_manipulation token = Token.create!(:user => @jsmith, :action => 'api') diff --git a/test/integration/webdav/dmsf_webdav_move_test.rb b/test/integration/webdav/dmsf_webdav_move_test.rb index 834f60fb..043237ac 100644 --- a/test/integration/webdav/dmsf_webdav_move_test.rb +++ b/test/integration/webdav/dmsf_webdav_move_test.rb @@ -30,8 +30,8 @@ class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest def setup DmsfLock.delete_all # Delete all locks that are in our test DB - probably not safe but ho hum timestamp = DateTime.now.strftime('%y%m%d%H%M') - Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path("./dmsf_test-#{timestamp}", DmsfHelper.temp_dir) - Dir.mkdir(DmsfFile.storage_path) unless File.directory?(DmsfFile.storage_path) + Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = DmsfHelper.temp_dir.join("dmsf_test-#{timestamp}").to_s + FileUtils.mkdir_p(DmsfFile.storage_path) unless DmsfFile.storage_path.exist? # Copy the physical files to the temporary storage files = File.expand_path('../../../fixtures/files', __FILE__) + '/.' FileUtils.cp_r files, DmsfFile.storage_path diff --git a/test/integration/webdav/dmsf_webdav_put_test.rb b/test/integration/webdav/dmsf_webdav_put_test.rb index 7f528c2c..661b6697 100644 --- a/test/integration/webdav/dmsf_webdav_put_test.rb +++ b/test/integration/webdav/dmsf_webdav_put_test.rb @@ -30,8 +30,8 @@ class DmsfWebdavPutTest < RedmineDmsf::Test::IntegrationTest def setup DmsfLock.delete_all # Delete all locks that are in our test DB - probably not safe but ho hum timestamp = DateTime.now.strftime("%y%m%d%H%M") - Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path("./dmsf_test-#{timestamp}", DmsfHelper.temp_dir) - Dir.mkdir(DmsfFile.storage_path) unless File.directory?(DmsfFile.storage_path) + Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = DmsfHelper.temp_dir.join("dmsf_test-#{timestamp}").to_s + FileUtils.mkdir_p(DmsfFile.storage_path) unless DmsfFile.storage_path.exist? @admin = credentials 'admin' @jsmith = credentials 'jsmith' @project1 = Project.find_by_id 1