1 byte files issue #1165

This commit is contained in:
karel.picman@lbcfree.net 2020-08-21 14:30:49 +02:00
parent 8d9201fc86
commit 63f8c92712
21 changed files with 79 additions and 5 deletions

View File

@ -277,7 +277,7 @@ class DmsfQuery < Query
1 AS sort #{cf_columns}}).
joins(:dmsf_file_revisions).
joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id ').
where('dmsf_file_revisions.created_at = (SELECT MAX(r.created_at) FROM dmsf_file_revisions r WHERE r.dmsf_file_id = dmsf_file_revisions.dmsf_file_id)')
where('dmsf_file_revisions.id = (SELECT r.id FROM dmsf_file_revisions r WHERE r.created_at = (SELECT MAX(created_at) FROM dmsf_file_revisions rr WHERE rr.dmsf_file_id = dmsf_files.id) ORDER BY id DESC LIMIT 1)')
if dmsf_folder_id
scope.where dmsf_files: { dmsf_folder_id: dmsf_folder_id, deleted: deleted }
else
@ -318,7 +318,7 @@ class DmsfQuery < Query
joins('JOIN dmsf_files ON dmsf_files.id = dmsf_links.target_id').
joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id').
joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id ').
where('dmsf_file_revisions.created_at = (SELECT MAX(r.created_at) FROM dmsf_file_revisions r WHERE r.dmsf_file_id = dmsf_file_revisions.dmsf_file_id)')
where('dmsf_file_revisions.id = (SELECT r.id FROM dmsf_file_revisions r WHERE r.created_at = (SELECT MAX(created_at) FROM dmsf_file_revisions rr WHERE rr.dmsf_file_id = dmsf_files.id) ORDER BY id DESC LIMIT 1)')
if dmsf_folder_id
scope.where dmsf_links: { target_type: 'DmsfFile', dmsf_folder_id: dmsf_folder_id, deleted: deleted }
else

View File

@ -237,6 +237,13 @@
<%= l(:note_webdav_ignore) %> <%= l(:label_default) %>: ^(\._|\.DS_Store$|Thumbs.db$)
</em>
</p>
<p>
<%= content_tag(:label, l(:dmsf_webdav_ignore_1b_file_for_authentication)) %>
<%= check_box_tag 'settings[dmsf_webdav_ignore_1b_file_for_authentication]', true, @settings['dmsf_webdav_ignore_1b_file_for_authentication'], size: 50 %>
<em class="info">
<%= l(:dmsf_webdav_ignore_1b_file_for_authentication_info) %> <%= l(:label_default) %>: <%= l(:general_text_Yes)%>
</em>
</p>
<p>
<%= content_tag :label, l(:label_webdav_disable_versioning) %>
<%= text_field_tag 'settings[dmsf_webdav_disable_versioning]', @settings['dmsf_webdav_disable_versioning'], size: 50 %>

View File

@ -408,6 +408,9 @@ cs:
label_add_width: Přidat s
dmsf_webdav_ignore_1b_file_for_authentication: Ignorovat 1b soubor poslaný kvůli autentizaci
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -407,6 +407,9 @@ de:
label_add_width: Zugeben mit
dmsf_webdav_ignore_1b_file_for_authentication: Ignoriern 1b Datai geschickt wegen der Autorization
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: Von mir gesperrte Dokumente

View File

@ -408,6 +408,9 @@ en:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ es:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ fr:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -407,6 +407,9 @@ hu:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ it: # Italian strings thx 2 Matteo Arceci!
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ ja:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: 自分がロック中の文書

View File

@ -407,6 +407,9 @@ ko:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: 내 잠긴 파일

View File

@ -408,6 +408,9 @@ nl:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ pl:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ pt-BR:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ ru:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ sl:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ zh-TW:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -408,6 +408,9 @@ zh:
label_add_width: Add with
dmsf_webdav_ignore_1b_file_for_authentication: Ignore 1b file sent for authentication
dmsf_webdav_ignore_1b_file_for_authentication_info: Total Commander WebDAV plugin
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -58,7 +58,8 @@ Redmine::Plugin.register :redmine_dmsf do
'dmsf_documents_email_reply_to' => '',
'dmsf_documents_email_links_only' => nil,
'dmsf_enable_cjk_ngrams' => nil,
'dmsf_webdav_use_project_names' => nil
'dmsf_webdav_use_project_names' => nil,
'dmsf_webdav_ignore_1b_file_for_authentication' => '1'
}
end

View File

@ -631,6 +631,12 @@ module RedmineDmsf
new_revision.size = request.content_length # Bad Guess
end
# Ignore 1b files sent for authentication
if Setting.plugin_redmine_dmsf['dmsf_webdav_ignore_1b_file_for_authentication'].present? && (new_revision.size == 1)
Rails.logger.info "1b file '#{basename}' sent for authentication ignored"
return NoContent
end
if new_revision.valid? && (!f.save)
Rails.logger.error f.errors.full_messages.to_sentence
raise InternalServerError

View File

@ -252,7 +252,6 @@ class DmsfWebdavPutTest < RedmineDmsf::Test::IntegrationTest
assert_response :created
end
original = Setting.plugin_redmine_dmsf['dmsf_webdav_disable_versioning']
Setting.plugin_redmine_dmsf['dmsf_webdav_disable_versioning'] = '.dump$'
put "/dmsf/webdav/#{@project1.identifier}/file3.dump", params: '1234', headers: credentials
assert_response :success
@ -266,7 +265,6 @@ class DmsfWebdavPutTest < RedmineDmsf::Test::IntegrationTest
put "/dmsf/webdav/#{@project1.identifier}/file3.dump", params: '9ABC', headers: credentials
assert_response :created
end
Setting.plugin_redmine_dmsf['dmsf_webdav_disable_versioning'] = original
end
def test_put_into_subproject
@ -299,5 +297,19 @@ class DmsfWebdavPutTest < RedmineDmsf::Test::IntegrationTest
@file1.last_revision.reload
assert_equal @file1.last_revision.custom_values.first.value, @cv22.value
end
def test_ignore_1b_files_on
Setting.plugin_redmine_dmsf['dmsf_webdav_ignore_1b_file_for_authentication'] = '1'
put "/dmsf/webdav/#{@project1.identifier}/1bfile.txt", params: '1',
headers: @jsmith.merge!({ content_type: :text })
assert_response :no_content
end
def test_ignore_1b_files_off
Setting.plugin_redmine_dmsf['dmsf_webdav_ignore_1b_file_for_authentication'] = ''
put "/dmsf/webdav/#{@project1.identifier}/1bfile.txt", params: '1',
headers: @jsmith.merge!({ content_type: :text })
assert_response :created
end
end