#9 Active Storage - settings

This commit is contained in:
Karel Pičman 2025-10-17 13:34:10 +02:00
parent e9450f9a5d
commit 50b1e1b6ef
29 changed files with 144 additions and 90 deletions

View File

@ -118,6 +118,8 @@ Rails/SkipsModelValidations:
- db/migrate/20140519133201_trash_bin.rb
- db/migrate/07_dmsf_1_4_4.rb
- db/migrate/20240829093801_rename_dmsf_digest_token.rb
- db/migrate/20251015130601_active_storage_migration.rb
- db/migrate/20251017101001_restore_updated_at.rb
Rails/ThreeStateBooleanColumn:
Exclude:
@ -130,6 +132,10 @@ Rails/UniqueValidationWithoutIndex:
- app/models/dmsf_file.rb
- app/models/dmsf_workflow_step.rb # Impossible due to steps sorting
Style/ClassVars:
Exclude:
- lib/redmine_dmsf.rb # @@xapian_available
Style/ExpandPathArguments:
Enabled: false

View File

@ -224,26 +224,28 @@ instance is stopped.
bundle config set --local without 'xapian'
bundle install
5. Initialize/Update database:
5. Install Active Storage => [Active Storage](#active-storage)
6. Enable WebDAV => [WebDAV](#webdav)
7. Initialize/Update database
`RAILS_ENV=production bundle exec rake redmine:plugins:migrate NAME=redmine_dmsf`
6. Install assets
8. Install assets
`RAILS_ENV="production" bundle exec rake assets:precompile`
7. The access rights must be set for web server, e.g.:
9. The access rights must be set for web server, e.g.:
`chown -R www-data:www-data plugins/redmine_dmsf`
8. Restart the web server, e.g.:
10. Restart the web server, e.g.:
`systemctl restart apache2`
9. You should configure the plugin via Redmine interface: Administration -> Plugins -> DMSF -> Configure. (You should check and then save the plugin's configuration after each upgrade.)
10. Don't forget to grant permissions for DMSF in Administration -> Roles and permissions
11. Assign DMSF permissions to appropriate roles.
12. There are a few rake tasks:
11. You should configure the plugin via Redmine interface: Administration -> Plugins -> DMSF -> Configure. (You should check and then save the plugin's configuration after each upgrade.)
12. Don't forget to grant permissions for DMSF in Administration -> Roles and permissions
13. Assign DMSF permissions to appropriate roles.
14. There are a few handy rake tasks:
I) To convert documents from the standard Redmine document module
@ -318,7 +320,6 @@ config.active_storage.service = :local # Store files locally
#config.active_storage.service = :amazon # Store files on Amazon S3
config.active_storage.analyzers.append RedmineDmsf::XapianAnalyzer # Index uploaded files for Xapian full-text search
```
Then install Active Storage with the following commands:
```shell

View File

@ -397,7 +397,7 @@ class DmsfFile < ApplicationRecord
results = scope.where(find_options).uniq.to_a
results.delete_if { |x| !DmsfFolder.permissions?(x.dmsf_folder) }
if !options[:titles_only] && RedmineDmsf::Plugin.lib_available?('xapian')
if !options[:titles_only] && RedmineDmsf.xapian_available
database = nil
begin
lang = RedmineDmsf.dmsf_stemming_lang

View File

@ -417,7 +417,7 @@ class DmsfFileRevision < ApplicationRecord
if derived_revisions.empty?
# Remove the file from Xapian index
RemoveFromIndexJob.schedule file.blob.key if RedmineDmsf::Plugin.lib_available?('xapian')
RemoveFromIndexJob.schedule file.blob.key if RedmineDmsf.xapian_available
# Remove the file
shared_file.purge_later if RedmineDmsf.physical_file_delete?
else

View File

@ -328,7 +328,7 @@
<%= l(:label_full_text) %>
</em>
<% if RedmineDmsf::Plugin.lib_available?('xapian') %>
<% if RedmineDmsf.xapian_available %>
<p>
<%= content_tag :label, l(:label_index_database) %>
<%= text_field_tag 'settings[dmsf_index_database]', RedmineDmsf.dmsf_index_database, size: 50 %>
@ -373,6 +373,14 @@
<%= l(:label_default)%>: <%= l(:general_text_No) %>
</em>
</p>
<p>
<%= content_tag :label, l(:label_maximum_xapian_filesize) %>
<%= text_field_tag 'settings[dmsf_max_xapian_filesize]', RedmineDmsf.dmsf_max_xapian_filesize, size: 10 %>
<em class="info">
<%= l(:note_maximum_xapian_filesize) %><br>
<%= l(:label_default) %>: 3
</em>
</p>
<% else %>
<p class="warning"><%= l(:warning_xapian_not_available) %></p>
<% end %>

View File

@ -70,7 +70,7 @@ cs:
link_modified: Změněno
link_ver: Ver.
link_author: Autor
title_check_for_zip_download_or_email: Vybrat pro stažení jako zip nebo emailem
title_check_for_zip_download_or_email: Vybrat pro stažení jako zip nebo e-mailem
title_check_for_restore_or_delete: Vybrat pro obnovení nebo smazání
title_notifications_active_deactivate: "Notifikace aktivní: Deaktivovat"
@ -82,9 +82,9 @@ cs:
title_unlock_file: Odemknout a umožnit změny ostatním uživatelům
title_lock_file: Zamknout a zabránit změnám ostatních uživatelů
title_download_checked: Stáhnout vybrané jako Zip
title_send_checked_by_email: Zaslat vybrané emailem
title_send_checked_by_email: Zaslat vybrané e-mailem
link_user_preferences: Vaše nastavení
heading_send_documents_by_email: Odeslat dokumenty emailem
heading_send_documents_by_email: Odeslat dokumenty e-mailem
label_email_from: Od
label_email_to: Komu
label_email_cc: Kopie
@ -125,7 +125,7 @@ cs:
option_version_custom: Vlastní
label_new_content: Nový obsah
label_maximum_files_download: Maximální počet najednou stažených souborů
note_maximum_number_of_files_downloaded: Maximální počet najednou stažených souborů jako Zip nebo odeslaných emailem.
note_maximum_number_of_files_downloaded: Maximální počet najednou stažených souborů jako Zip nebo odeslaných e-mailem.
0 znamená bez omezení.
label_file_storage_directory: Složka pro uložení souborů
label_index_database: Index databáze
@ -144,8 +144,8 @@ cs:
label_default_notifications: Výchozí notifikace pro soubory
heading_uploaded_files: Nahrané soubory
link_documents: Dokumenty
permission_view_dmsf_file_revision_accesses: View downloads in Activity stream
permission_view_dmsf_file_revisions: View revisions in Activity stream
permission_view_dmsf_file_revision_accesses: Zobrazit stažení v aktivitách
permission_view_dmsf_file_revisions: Zobrazit revize v aktivitách
permission_view_dmsf_folders: Procházet dokumenty
permission_user_preferences: Nastavení uživatele
permission_view_dmsf_files: Zobrazit dokumenty
@ -155,8 +155,8 @@ cs:
permission_manage_workflows: Spravovat schvalovací procesy
permission_file_delete: Mazat dokumenty
permission_display_system_folders: Zobrazit systémové složky
permission_file_approval: File approval
permission_email_documents: Email documents
permission_file_approval: Schvalovat dokumenty
permission_email_documents: Posílat dokumenty e-mailem
label_file: Soubor
field_folder: Složka
error_file_commit_require_uploaded_file: Potvrzení vyžaduje nahraný soubor
@ -182,7 +182,7 @@ cs:
menu_dmsf: DMS # Project tab title
label_physical_file_delete: Fyzické smazání souboru
user_is_not_project_member: Nejste členem projektu
heading_access_downloads_emails: Stažené/Emaily
heading_access_downloads_emails: Stažené/E-maily
heading_access_first: První
heading_access_last: Poslední
label_dmsf_updated: Změněno
@ -199,11 +199,11 @@ cs:
error_target_folder_same: Cílový složka a projekt jsou stejné jako aktuální
title_copy: Kopírovat
error_max_email_filesize_exceeded: "Přesáhli jste maximální velikost souboru, který lze poslat emailem.
error_max_email_filesize_exceeded: "Přesáhli jste maximální velikost souboru, který lze poslat e-mailem.
(%{number} MB)"
note_maximum_email_filesize: Omezí se maximální velikost souboru, který může být poslán emailem. 0 znamená neomezený.
note_maximum_email_filesize: Omezí se maximální velikost souboru, který může být poslán e-mailem. 0 znamená neomezený.
Číslo je v MB.
label_maximum_email_filesize: Maximální velikost souboru emailu
label_maximum_email_filesize: Maximální velikost souboru e-mailu
header_minimum_filesize: Chyba souboru.
error_minimum_filesize: "Soubor %{file} má nulovou velikost a nebude přiložen."
parent_directory: Nadřazená složka
@ -317,9 +317,9 @@ cs:
label_links_only: pouze odkazy
label_display_notified_recipients: Zobrazit příjemce notifikací
note_display_notified_recipients: Uživatel bude informován o příjemcích právě odeslané emailové notifikace.
note_display_notified_recipients: Uživatel bude informován o příjemcích právě odeslané e-mailové notifikace.
warning_email_notifications: "Notifikační email poslán na uživatele %{to}"
warning_email_notifications: "Notifikační e-mail poslán na uživatele %{to}"
link_trash_bin: Koš
title_restore: Obnovit
@ -384,8 +384,7 @@ cs:
label_enable_cjk_ngrams: Povolit generování n-gramů pro CJK texty
text_enable_cjk_ngrams: "Pokud je povoleno, sekvence čínských nebo japonských znaků jsou rozděleny do jednotlivých
znaků nebo skupin znaků. Znaky si nesou informaci o své pozici. Znaky psané latinkou jsou rozděleny normálně do
slov. Odpovídající proměná prostředí musí být použita při indexaci.
např.: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
slov."
label_dmsf_fast_links: Rychlé odkazy
text_dmsf_fast_links_info: Při vytváření odkazů budete moci zadat přímo ID cílové složky za účelem zrychlení
@ -493,6 +492,10 @@ cs:
warning_folder_unlockable: Složku nelze odemknout
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximální velikost souboru pro indexaci
note_maximum_xapian_filesize: Omezuje maximální velikost souboru pro indexaci. Větší soubory nebudou indexovány.
Velikost je v MB.
activerecord:
errors:
messages:

View File

@ -378,9 +378,7 @@ de:
label_enable_cjk_ngrams: Aktiviere die Erstellung von n-grams aus Koreanischen Texten
text_enable_cjk_ngrams: "Mit dieser Aktivierung werden Koreanische Zeichenfolgen in Monograms and Bigrams zerlegt.
Monograms enthalten Informationen zur Position. Nicht-Koreanische Zeichenfolgen werden in Wörter zerlegt. Die entsprechende
Option muss beim Indexieren verwendet werden,
z.B. XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
Monograms enthalten Informationen zur Position. Nicht-Koreanische Zeichenfolgen werden in Wörter zerlegt."
label_dmsf_fast_links: Schnelle Verknüpfung
text_dmsf_fast_links_info: Ermöglicht durch Eingabe der Ordner-ID auf einfache Art und Weise eine Verknüpfung
@ -489,6 +487,10 @@ de:
warning_folder_unlockable: Der Ordner kann nicht entsperrt werden
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximale Dateigröße für den Index
note_maximum_xapian_filesize: Begrenzt die maximale Dateigröße für die Indizierung. Größere Dateien werden nicht
indiziert. Angabe in MB.
activerecord:
errors:
messages:

View File

@ -382,9 +382,7 @@ en:
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -492,6 +490,9 @@ en:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -382,9 +382,7 @@ es:
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -492,6 +490,9 @@ es:
label_dmsf_commit: Commit
label_dmsf_upload_commit: Upload and commit
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -471,6 +471,9 @@ fa:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -382,9 +382,7 @@ fr:
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -492,6 +490,9 @@ fr:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -381,9 +381,7 @@ hu:
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -491,6 +489,9 @@ hu:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -382,9 +382,7 @@ it: # Italian strings thx 2 Matteo Arceci!
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -492,6 +490,9 @@ it: # Italian strings thx 2 Matteo Arceci!
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -382,9 +382,7 @@ ja:
label_enable_cjk_ngrams: CJKテキストから n-grams の生成を有効にする
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: 高速リンク
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -493,6 +491,9 @@ ja:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -381,10 +381,8 @@ ko:
label_email_reply_to: 회신
label_enable_cjk_ngrams: CJK 텍스트로부터 n-gram 생성을 활성화
text_enable_cjk_ngrams: "이 기능을 사용하면 CJK 문자 범위가 유니그램과 바이그램으로 분할되고, 유니그램은 위치 정보를 전달합니다. CJK 범위 외의 문자는 일반적인 단어로 분할됩니다. 해당 옵션은 색인 시점에 사용됩니다. 예: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
text_enable_cjk_ngrams: "이 기능을 사용하면 CJK 문자 범위가 유니그램과 바이그램으로 분할되고, 유니그램은 위치 정보를 전달합니다.
CJK 범위 외의 문자는 일반적인 단어로 분할됩니다."
label_dmsf_fast_links: 빠른 링크
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -492,6 +490,9 @@ ko:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -492,6 +492,9 @@ nl:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -382,9 +382,7 @@ pl:
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -492,6 +490,9 @@ pl:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -382,9 +382,7 @@ pt-BR:
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -492,6 +490,9 @@ pt-BR:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -382,9 +382,7 @@ sl:
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -492,6 +490,9 @@ sl:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -383,10 +383,7 @@ uk:
label_enable_cjk_ngrams: Дозводити генерацію n-грам з тексту CJK
text_enable_cjk_ngrams: "Якщо ввімкнено цю функцію, діапазони символів CJK розбиваються на уніграми і біграми, при
цьому уніграми містять позиційну інформацію. Символи, відмінні від CJK, розбиваються на слова як зазвичай.
Відповідна опція повинна бути використана під час індексування
Приклад: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
цьому уніграми містять позиційну інформацію. Символи, відмінні від CJK, розбиваються на слова як зазвичай."
label_dmsf_fast_links: Швидкі посилання
text_dmsf_fast_links_info: Ви зможете вручну ввести ідентифікатор кінцевої папки під час створення посилань або
переміщення файлів чи папок, щоб пришвидшити процес створення посилань.
@ -494,6 +491,9 @@ uk:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -381,9 +381,8 @@ zh-TW:
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -491,6 +490,9 @@ zh-TW:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -382,9 +382,7 @@ zh:
label_enable_cjk_ngrams: Enable generation of n-grams from CJK text
text_enable_cjk_ngrams: "With this enabled, spans of CJK characters are split into unigrams and bigrams, with the
unigrams carrying positional information. Non-CJK characters are split into words as normal. The corresponding
option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
unigrams carrying positional information. Non-CJK characters are split into words as normal."
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links or moving files
@ -492,6 +490,9 @@ zh:
warning_folder_unlockable: The folder can't be unlocked
redmine_dmsf: Redmine DMSF
label_maximum_xapian_filesize: Maximum Xapian file size
note_maximum_xapian_filesize: Limits maximum filesize for indexing. Larger files won't be indexed. Number is in MB.
activerecord:
errors:
messages:

View File

@ -24,8 +24,8 @@ class ActiveStorageMigration < ActiveRecord::Migration[7.0]
$stdout.puts 'It could be a very long process. Be patient...'
# We need to keep updated_at column unchanged and due to the asynchronous file analysis there is probably no better
# way how to achieve that.
add_column :dmsf_file_revisions, :temp_updated_at, :datetime, default: nil,
null: true, if_not_exists: true
add_column :dmsf_file_revisions, :temp_updated_at, :datetime,
default: nil, null: true, if_not_exists: true
DmsfFileRevision.update_all 'temp_updated_at = updated_at'
# Remove the Xapian database as it will be rebuilt from scratch during the migration
if xapian_database_removed?
@ -93,7 +93,7 @@ class ActiveStorageMigration < ActiveRecord::Migration[7.0]
# Delete Xapian database
def xapian_database_removed?
if RedmineDmsf::Plugin.lib_available?('xapian')
if RedmineDmsf::Plugin.xapian_available
FileUtils.rm_rf File.join(RedmineDmsf.dmsf_index_database, RedmineDmsf.dmsf_stemming_lang)
true
else

View File

@ -62,7 +62,8 @@ Redmine::Plugin.register :redmine_dmsf do
'empty_minor_version_by_default' => '0',
'remove_original_documents_module' => '0',
'dmsf_webdav_authentication' => 'Digest',
'dmsf_really_delete_files' => '0'
'dmsf_really_delete_files' => '0',
'dmsf_max_xapian_filesize' => 3
}
end

View File

@ -19,6 +19,18 @@
# Main module
module RedmineDmsf
# Return true if the given gem is installed
def self.lib_available?(path)
require path
true
rescue LoadError => e
Rails.logger.debug e.message
false
end
mattr_accessor :xapian_available, instance_writer: false
@@xapian_available = RedmineDmsf.lib_available?('xapian')
# Settings
class << self
def dmsf_max_file_download
@ -211,6 +223,14 @@ module RedmineDmsf
value = Setting.plugin_redmine_dmsf['dmsf_default_notifications']
value.to_i.positive? || value == 'true'
end
def dmsf_max_xapian_filesize
if Setting.plugin_redmine_dmsf['dmsf_max_xapian_filesize'].present?
Setting.plugin_redmine_dmsf['dmsf_max_xapian_filesize'].to_i
else
3
end
end
end
end

View File

@ -39,4 +39,4 @@ module RedmineDmsf
end
# Apply the patch
Puma::Const.include RedmineDmsf::Patches::PumaPatch if RedmineDmsf::Plugin.lib_available?('puma/const')
Puma::Const.include RedmineDmsf::Patches::PumaPatch if RedmineDmsf.lib_available?('puma/const')

View File

@ -36,14 +36,5 @@ module RedmineDmsf
end
false
end
# Return true if the given gem is installed
def self.lib_available?(path)
require path
true
rescue LoadError => e
Rails.logger.debug e.message
false
end
end
end

View File

@ -21,7 +21,8 @@ module RedmineDmsf
# ActiveRecord Analyzer for Xapian
class XapianAnalyzer < ActiveStorage::Analyzer
def self.accept?(blob)
return false unless RedmineDmsf::Plugin.lib_available?('xapian') && blob.byte_size < 1_024 * 1_024 * 3 # 3MB
return false unless RedmineDmsf.xapian_available &&
blob.byte_size < 1_024 * 1_024 * RedmineDmsf.dmsf_max_xapian_filesize # MB
@blob = blob
true
@ -38,10 +39,11 @@ module RedmineDmsf
db_path = File.join RedmineDmsf.dmsf_index_database, stem_lang
url = File.join(@blob.key[0..1], @blob.key[2..3])
dir = File.join(Dir.tmpdir, @blob.key)
env = 'XAPIAN_CJK_NGRAM=true ' if RedmineDmsf.dmsf_enable_cjk_ngrams?
FileUtils.mkdir dir
@blob.open do |file|
FileUtils.mv file.path, File.join(dir, @blob.key)
system "omindex -s \"#{stem_lang}\" -D \"#{db_path}\" --url=/#{url} \"#{dir}\" -p", exception: true
system "#{env}omindex -s \"#{stem_lang}\" -D \"#{db_path}\" --url=/#{url} \"#{dir}\" -p", exception: true
end
true
rescue StandardError => e

View File

@ -43,8 +43,9 @@ class DmsfPluginTest < RedmineDmsf::Test::HelperTest
FileUtils.rm_rf path
end
# TODO: move it elswhere
def test_lib_available?
assert RedmineDmsf::Plugin.lib_available?('zip')
assert_not RedmineDmsf::Plugin.lib_available?('not_existing_gem')
assert RedmineDmsf.lib_available?('zip')
assert_not RedmineDmsf.lib_available?('not_existing_gem')
end
end