Disable versioning for certain files/file patterns #630
This commit is contained in:
parent
c985a882d1
commit
f7051c7ba0
@ -124,7 +124,7 @@
|
||||
<%= content_tag(:label, l(:label_title_format)) %>
|
||||
<%= text_field_tag 'settings[dmsf_global_title_format]', @settings['dmsf_global_title_format'], :size => 10 %>
|
||||
<em class="info">
|
||||
<%= l(:text_title_format) %> <%= l(:label_default) %>: %t_%v
|
||||
<%= l(:text_title_format) %>
|
||||
</em>
|
||||
</p>
|
||||
|
||||
@ -164,26 +164,33 @@
|
||||
</em>
|
||||
</p>
|
||||
|
||||
<% if @settings['dmsf_webdav'].nil? || !@settings['dmsf_webdav'].empty? %>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_webdav_strategy)) %>
|
||||
<%= select_tag('settings[dmsf_webdav_strategy]',
|
||||
options_for_select([
|
||||
[l(:select_option_webdav_readonly), 'WEBDAV_READ_ONLY'],
|
||||
[l(:select_option_webdav_readwrite), 'WEBDAV_READ_WRITE']],
|
||||
:selected => @settings['dmsf_webdav_strategy'])) %><br/>
|
||||
<em class="info">
|
||||
<%= l(:note_webdav_strategy).html_safe %> <%= l(:label_default) %>: <%= l(:select_option_webdav_readonly) %>
|
||||
</em>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_memcached_servers)) %>
|
||||
<%= text_field_tag 'settings[dmsf_memcached_servers]', @settings['dmsf_memcached_servers'], :size => 50 %>
|
||||
<em class="info">
|
||||
<%= l(:text_memcached_servers) %>
|
||||
</em>
|
||||
</p>
|
||||
<% end %>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_webdav_strategy)) %>
|
||||
<%= select_tag('settings[dmsf_webdav_strategy]',
|
||||
options_for_select([
|
||||
[l(:select_option_webdav_readonly), 'WEBDAV_READ_ONLY'],
|
||||
[l(:select_option_webdav_readwrite), 'WEBDAV_READ_WRITE']],
|
||||
:selected => @settings['dmsf_webdav_strategy'])) %><br/>
|
||||
<em class="info">
|
||||
<%= l(:note_webdav_strategy).html_safe %> <%= l(:label_default) %>: <%= l(:select_option_webdav_readonly) %>
|
||||
</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_memcached_servers)) %>
|
||||
<%= text_field_tag 'settings[dmsf_memcached_servers]', @settings['dmsf_memcached_servers'], :size => 50 %>
|
||||
<em class="info">
|
||||
<%= l(:text_memcached_servers) %>
|
||||
</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_webdav_ignore)) %>
|
||||
<%= text_field_tag 'settings[dmsf_webdav_ignore]', @settings['dmsf_webdav_ignore'], :size => 50 %>
|
||||
<em class="info">
|
||||
<%= l(:note_webdav_ignore) %> <%= l(:label_default) %>: ^(\._|\.DS_Store$|Thumbs.db$)
|
||||
</em>
|
||||
</p>
|
||||
|
||||
<hr/>
|
||||
<em class="info">
|
||||
|
||||
@ -341,4 +341,7 @@ cs:
|
||||
link_extension: Příp.
|
||||
|
||||
label_memcached_servers: Adresa Memcached serveru
|
||||
text_memcached_servers: Je podporován pouze jeden server. Pokud není vyplněno, kešování je vypnuté. Při změně adresy je potřeba restartovat aplikaci.
|
||||
text_memcached_servers: Je podporován pouze jeden server. Pokud není vyplněno, kešování je vypnuté. Při změně adresy je potřeba restartovat aplikaci.
|
||||
|
||||
label_webdav_ignore: Vzory názvů ignorovaných souborů
|
||||
note_webdav_ignore: Regulární výraz pro názvy souborů, které budou ignorovány při volání PUT.
|
||||
@ -341,4 +341,7 @@ de:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached Server Adresse
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -342,3 +342,6 @@ en:
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ es:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ fr:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ it: # Italian strings thx 2 Matteo Arceci!
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ ja:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ pl:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ pt-BR:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ ru:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ sl:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ zh-TW:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
@ -341,4 +341,7 @@ zh:
|
||||
link_extension: Ext
|
||||
|
||||
label_memcached_servers: Memcached server address
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted!
|
||||
|
||||
label_webdav_ignore: Ignored files patterns
|
||||
note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests.
|
||||
3
init.rb
3
init.rb
@ -48,7 +48,8 @@ Redmine::Plugin.register :redmine_dmsf do
|
||||
'dmsf_display_notified_recipients' => 0,
|
||||
'dmsf_global_title_format' => '',
|
||||
'dmsf_columns' => %w(title size modified version workflow author),
|
||||
'dmsf_memcached_servers' => ''
|
||||
'dmsf_memcached_servers' => '',
|
||||
'dmsf_webdav_ignore' => '^(\._|\.DS_Store$|Thumbs.db$)'
|
||||
}
|
||||
|
||||
menu :project_menu, :dmsf, { :controller => 'dmsf', :action => 'show' }, :caption => :menu_dmsf, :before => :documents, :param => :id
|
||||
|
||||
@ -533,13 +533,12 @@ module RedmineDmsf
|
||||
|
||||
# HTTP PUT request.
|
||||
def put(request, response)
|
||||
Rails.logger.info ">>> 1"
|
||||
raise BadRequest if collection?
|
||||
Rails.logger.info ">>> 2"
|
||||
raise Forbidden unless User.current.admin? || User.current.allowed_to?(:file_manipulation, project)
|
||||
Rails.logger.info ">>> 3"
|
||||
# Ignore Mac OS X resource forks and special Windows files.
|
||||
if basename.match(/^\._/) || basename.match(/^\.DS_Store$/i) || basename.match(/^Thumbs.db$/i)
|
||||
# Ignore file name patterns given in the plugin settings
|
||||
pattern = Setting.plugin_redmine_dmsf['dmsf_webdav_ignore']
|
||||
pattern = /^(\._|\.DS_Store$|Thumbs.db$)/ if pattern.blank?
|
||||
if basename.match(pattern)
|
||||
Rails.logger.info "#{basename} ignored"
|
||||
return NoContent
|
||||
end
|
||||
|
||||
@ -207,4 +207,21 @@ class DmsfWebdavPutTest < RedmineDmsf::Test::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
def test_put_ignored_files_default
|
||||
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
|
||||
@project1.enable_module! :dmsf
|
||||
@role.add_permission! :view_dmsf_folders
|
||||
@role.add_permission! :file_manipulation
|
||||
put "/dmsf/webdav/#{@project1.identifier}/._test.txt", '1234', @admin.merge!({:content_type => :text})
|
||||
assert_response 204 # NoContent
|
||||
put "/dmsf/webdav/#{@project1.identifier}/.DS_Store", '1234', @admin.merge!({:content_type => :text})
|
||||
assert_response 204 # NoContent
|
||||
put "/dmsf/webdav/#{@project1.identifier}/Thumbs.sb", '1234', @admin.merge!({:content_type => :text})
|
||||
assert_response 204 # NoContent
|
||||
Setting.plugin_redmine_dmsf['dmsf_webdav_ignore'] = '.dump$'
|
||||
put "/dmsf/webdav/#{@project1.identifier}/test.dump", '1234', @admin.merge!({:content_type => :text})
|
||||
assert_response 204 # NoContent
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user