From 6a1985255fb830c23441a90a99e400a60530c250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Wed, 4 Oct 2023 10:52:25 +0200 Subject: [PATCH] Failed upgrade up to version 3.1.1 from version 3.0.12 #1472 --- Gemfile | 4 +- README.md | 11 +++ app/models/dmsf_file.rb | 4 +- app/views/settings/_dmsf_settings.html.erb | 88 ++++++++++++---------- config/locales/cs.yml | 1 + config/locales/de.yml | 1 + config/locales/en.yml | 1 + config/locales/es.yml | 1 + config/locales/fa.yml | 1 + config/locales/fr.yml | 1 + config/locales/hu.yml | 1 + config/locales/it.yml | 1 + config/locales/ja.yml | 1 + config/locales/ko.yml | 1 + config/locales/nl.yml | 1 + config/locales/pl.yml | 1 + config/locales/pt-BR.yml | 1 + config/locales/sl.yml | 1 + config/locales/ua.yml | 1 + config/locales/zh-TW.yml | 1 + config/locales/zh.yml | 1 + lib/redmine_dmsf/plugin.rb | 9 +++ 22 files changed, 91 insertions(+), 42 deletions(-) diff --git a/Gemfile b/Gemfile index b2b0ea26..02283b75 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,9 @@ source 'https://rubygems.org' do gem 'ox' # Dav4Rack gem 'rake' unless Dir.exist?(File.expand_path('../../redmine_dashboard', __FILE__)) gem 'uuidtools' - gem 'xapian-ruby' + group :xapian do + gem 'xapian-ruby' + end gem 'zip-zip' unless Dir.exist?(File.expand_path('../../vault', __FILE__)) # Redmine extensions diff --git a/README.md b/README.md index 212dc45a..38e42b38 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,17 @@ instance is stopped. 4. Install dependencies: `bundle install` + + 4.1 In production environment + + bundle config set --local without 'development test` + bundle install + + 4.2 Without Xapian fulltext search (on Windows) + + bundle config set --local without 'xapian' + bundle install + 5. Initialize/Update database: `RAILS_ENV=production bundle exec rake redmine:plugins:migrate NAME=redmine_dmsf` diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index efda5a0d..67728454 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -18,8 +18,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -require 'xapian' require "#{File.dirname(__FILE__)}/../../lib/redmine_dmsf/lockable" require 'English' @@ -368,7 +366,7 @@ class DmsfFile < ApplicationRecord results = scope.where(find_options).uniq.to_a results.delete_if { |x| !DmsfFolder.permissions?(x.dmsf_folder) } - unless options[:titles_only] + if !options[:titles_only] && RedmineDmsf::Plugin.xapian_available? database = nil begin lang = Setting.plugin_redmine_dmsf['dmsf_stemming_lang'].strip diff --git a/app/views/settings/_dmsf_settings.html.erb b/app/views/settings/_dmsf_settings.html.erb index ab2b5759..063aa228 100644 --- a/app/views/settings/_dmsf_settings.html.erb +++ b/app/views/settings/_dmsf_settings.html.erb @@ -343,46 +343,58 @@

<% else %> -

- <%= content_tag :label, l(:label_index_database) %> - <%= text_field_tag 'settings[dmsf_index_database]', @settings['dmsf_index_database'], size: 50 %> - - <%= l(:label_default) %>: <%= File.expand_path('dmsf_index', Rails.root) %> - -

+ <% begin %> + <% require 'xapian' %> + <% xapian_disabled = false %> + <% rescue LoadError => e %> +

<%= l(:warning_xapian_not_available) %>

+ <% Rails.logger.warn e.message %> + <% xapian_disabled = true %> + <% end %> + <% if RedmineDmsf::Plugin.xapian_available? %> +

+ <%= content_tag :label, l(:label_index_database) %> + <%= text_field_tag 'settings[dmsf_index_database]', @settings['dmsf_index_database'], size: 50 %> + + <%= l(:label_default) %>: <%= File.expand_path('dmsf_index', Rails.root) %> + +

- <% stem_langs = %w(danish dutch english finnish french german hungarian italian norwegian portuguese romanian russian - spanish swedish turkish) %> + <% stem_langs = %w(danish dutch english finnish french german hungarian italian norwegian portuguese romanian russian + spanish swedish turkish) %> -

- <%= content_tag :label, l(:label_stemming_language) %> - <%= select_tag 'settings[dmsf_stemming_lang]', options_for_select(stem_langs, @settings['dmsf_stemming_lang']) %> - - <%= l(:note_possible_values) %>: <%= stem_langs.join(', ') %>. <%= "#{l(:label_default)}: #{stem_langs[2]}" %> - -

+

+ <%= content_tag :label, l(:label_stemming_language) %> + <%= select_tag 'settings[dmsf_stemming_lang]', options_for_select(stem_langs, @settings['dmsf_stemming_lang']) %> + + <%= l(:note_possible_values) %>: <%= stem_langs.join(', ') %>. <%= "#{l(:label_default)}: #{stem_langs[2]}" %> + +

-

- <%= content_tag :label, l(:label_stem_strategy) %> - <%= radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_NONE', - @settings['dmsf_stemming_strategy'] == 'STEM_NONE', checked: true %> <%= l(:option_stem_none) %> -
- <%= radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_SOME', - @settings['dmsf_stemming_strategy'] == 'STEM_SOME' %> <%= l(:option_stem_some) %> -
- <%= radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_ALL', - @settings['dmsf_stemming_strategy'] == 'STEM_ALL' %> <%= l(:option_stem_all) %> -
- - <%= l(:text_stemming_info) %> - -

+

+ <%= content_tag :label, l(:label_stem_strategy) %> + <%= radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_NONE', + @settings['dmsf_stemming_strategy'] == 'STEM_NONE', checked: true %> <%= l(:option_stem_none) %> +
+ <%= radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_SOME', + @settings['dmsf_stemming_strategy'] == 'STEM_SOME' %> <%= l(:option_stem_some) %> +
+ <%= radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_ALL', + @settings['dmsf_stemming_strategy'] == 'STEM_ALL' %> <%= l(:option_stem_all) %> +
+ + <%= l(:text_stemming_info) %> + +

-

- <%= content_tag :label, l(:label_enable_cjk_ngrams) %> - <%= check_box_tag 'settings[dmsf_enable_cjk_ngrams]', true, @settings['dmsf_enable_cjk_ngrams'] %> - - <%= l(:text_enable_cjk_ngrams) %> - -

+

+ <%= content_tag :label, l(:label_enable_cjk_ngrams) %> + <%= check_box_tag 'settings[dmsf_enable_cjk_ngrams]', true, @settings['dmsf_enable_cjk_ngrams'] %> + + <%= l(:text_enable_cjk_ngrams) %> + +

+ <% else %> +

<%= l(:warning_xapian_not_available) %>

+ <% end %> <% end %> diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 861af820..cd665c97 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -180,6 +180,7 @@ cs: error_file_can_not_be_created: Nelze vytvořit soubor v cílové složce error_wrong_zip_encoding: Chybné kódování Zipu + warning_xapian_not_available: Xapian není k dostupný menu_dmsf: DMS # Project tab title label_physical_file_delete: Fyzické smazání souboru user_is_not_project_member: Nejste členem projektu diff --git a/config/locales/de.yml b/config/locales/de.yml index 79cf7575..1ffa24f7 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -177,6 +177,7 @@ de: erstellt werden. error_file_can_not_be_created: Datei kann nicht in dem gewählten Ordner erstellt werden. error_wrong_zip_encoding: Falsche ZIP-Kodierung + warning_xapian_not_available: Xapian steht nicht zur Verfügung menu_dmsf: DMS # Project tab title label_physical_file_delete: Datei physisch löschen user_is_not_project_member: Sie sind kein Projektmitglied diff --git a/config/locales/en.yml b/config/locales/en.yml index 5e357b4b..18cdfa00 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -180,6 +180,7 @@ en: 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 label_physical_file_delete: Physical file delete user_is_not_project_member: You are not a member of the project diff --git a/config/locales/es.yml b/config/locales/es.yml index 1f22f84c..81f5dd9b 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -180,6 +180,7 @@ es: error_file_can_not_be_created: "El archivo no puede ser creado en el directorio destino" error_wrong_zip_encoding: Codificación erronea de Zip + warning_xapian_not_available: Xapian no disponible menu_dmsf: DMS # Project tab title label_physical_file_delete: Eliminar archivos físicos user_is_not_project_member: No es miemo del proyecto diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 5593c601..5e26f571 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -174,6 +174,7 @@ fa: error_file_can_not_be_created: "پرونده‌ها نمی‌توانند در پوشه‌ی ذخیره‌سازی ساخته شوند." error_wrong_zip_encoding: رمزگذاری اشتباه zip + warning_xapian_not_available: Xapian در دسترس نیست menu_dmsf: اسناد پیش‌رفته # Project tab title label_physical_file_delete: پرونده فیزیکی حذف شود user_is_not_project_member: شما عضو این پروژه نیستید diff --git a/config/locales/fr.yml b/config/locales/fr.yml index dbaeb39b..39406403 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -180,6 +180,7 @@ fr: créé error_file_can_not_be_created: "Le fichier n'a pas pu être enregistré dans le répertoire de stockage" error_wrong_zip_encoding: Mauvais jeu de caractères pour la transformation du nom du ZIP + warning_xapian_not_available: Le module Xapian est indisponible menu_dmsf: DMS # Project tab title label_physical_file_delete: Suppression des fichiers user_is_not_project_member: "Vous n'êtes pas un membre du projet" diff --git a/config/locales/hu.yml b/config/locales/hu.yml index cdfa7365..651434af 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -180,6 +180,7 @@ hu: error_file_can_not_be_created: A fájl nem hozható létre a tárolómappában error_wrong_zip_encoding: Nem megfelelő Zip kódolás + warning_xapian_not_available: Xapian nem elérhető menu_dmsf: DMS # Project tab title label_physical_file_delete: Fizikai fájl törölve lett user_is_not_project_member: Ön nem tagja a csoportnak diff --git a/config/locales/it.yml b/config/locales/it.yml index eae04e29..0e913915 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -180,6 +180,7 @@ it: # Italian strings thx 2 Matteo Arceci! error_file_can_not_be_created: "Il documento non può essere creato nella cartella di archiviazione" error_wrong_zip_encoding: Errato encoding dello Zip + warning_xapian_not_available: Xapian non disponibile menu_dmsf: Documenti # Project tab title label_physical_file_delete: File fisico eliminato user_is_not_project_member: Non sei un membro del progetto diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 2e7df658..fdde9fde 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -180,6 +180,7 @@ ja: error_file_can_not_be_created: ファイルを保存フォルダに作成できません error_wrong_zip_encoding: Zip エンコーディングが正しくありません + warning_xapian_not_available: Xapian は利用できません menu_dmsf: 文書管理 # Project tab title label_physical_file_delete: 物理ファイルの削除 user_is_not_project_member: あなたはプロジェクトのメンバーではありません diff --git a/config/locales/ko.yml b/config/locales/ko.yml index ffb54741..b156cfe4 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -180,6 +180,7 @@ ko: error_file_can_not_be_created: 저장 공간에 파일을 생성할 수 없습니다 error_wrong_zip_encoding: 올바르지 않은 Zip 인코딩 + warning_xapian_not_available: Xapian을 사용할 수 없습니다 menu_dmsf: DMS label_physical_file_delete: 파일 삭제됨 user_is_not_project_member: 이 프로젝트의 구성원이 아닙니다 diff --git a/config/locales/nl.yml b/config/locales/nl.yml index abc546d9..0d59f81b 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -180,6 +180,7 @@ nl: error_file_can_not_be_created: Bestand kan niet aangemaakt worden in opslag directory error_wrong_zip_encoding: Onjuiste Zip encoding + warning_xapian_not_available: Xapian niet beschikbaar menu_dmsf: Easy DMS label_physical_file_delete: Fysiek bestand verwijderen user_is_not_project_member: U bent geen lid van het project diff --git a/config/locales/pl.yml b/config/locales/pl.yml index d97ab0d6..deee5de6 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -179,6 +179,7 @@ pl: error_file_can_not_be_created: "Plik nie może zostać utworzony w folderze przechowywania" error_wrong_zip_encoding: Złe kodowanie Zip + warning_xapian_not_available: Xapian niedostępny menu_dmsf: DMS # Project tab title label_physical_file_delete: Fizyczne usuwanie plików user_is_not_project_member: Nie jesteś przypisany do tego projektu diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 61723436..aa00ce89 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -180,6 +180,7 @@ pt-BR: criado" error_file_can_not_be_created: "O arquivo não pode ser criado" error_wrong_zip_encoding: Código Zip errado + warning_xapian_not_available: Xapian não disponível menu_dmsf: DMS label_physical_file_delete: Excluir fisicamente arquivo user_is_not_project_member: Você não é um membro do projeto diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 921e1317..91da2a6d 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -180,6 +180,7 @@ sl: error_file_can_not_be_created: Datoteke se ne da kreirat v mapi error_wrong_zip_encoding: Napačen Zip nabor znakov + warning_xapian_not_available: Xapian ni na voljo menu_dmsf: Arhiv # Project tab title label_physical_file_delete: Brisanje datoteke (fizično) user_is_not_project_member: Niste član projekta diff --git a/config/locales/ua.yml b/config/locales/ua.yml index 23c1ffe6..3a2767a4 100644 --- a/config/locales/ua.yml +++ b/config/locales/ua.yml @@ -181,6 +181,7 @@ uk: error_file_can_not_be_created: "Неможливо створити файли в каталозі/директорії зберігання" error_wrong_zip_encoding: Неправильне Zip-кодування + warning_xapian_not_available: Xapian not available menu_dmsf: DMS # Project tab title - Заголовок вкладки DMS # Project label_physical_file_delete: Фізичний файл видалено user_is_not_project_member: Ви не є учасником проекту diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 416d3aac..7370b89d 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -180,6 +180,7 @@ zh-TW: error_file_can_not_be_created: 在存儲目錄裡,無法建立檔案。 error_wrong_zip_encoding: 不正確的Zip encoding + warning_xapian_not_available: Xapian not available menu_dmsf: 文件總管 # Project tab title label_physical_file_delete: 永久刪除檔案 user_is_not_project_member: 您不是專案的成員之一 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 1212cb34..baa75c77 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -180,6 +180,7 @@ zh: error_file_can_not_be_created: 文件未能在存储目录中创建 error_wrong_zip_encoding: 不正确的Zip编码 + warning_xapian_not_available: Xapian not available menu_dmsf: 文档管家 # Project tab title label_physical_file_delete: 物理删除文件 user_is_not_project_member: 您不是该项目的成员 diff --git a/lib/redmine_dmsf/plugin.rb b/lib/redmine_dmsf/plugin.rb index 9fdae99d..e3037853 100644 --- a/lib/redmine_dmsf/plugin.rb +++ b/lib/redmine_dmsf/plugin.rb @@ -39,5 +39,14 @@ module RedmineDmsf end false end + + # Return true if Xapian binding is installed (gem ruby_xapian) + def self.xapian_available? + require 'xapian' + true + rescue LoadError => e + Rails.logger.warn e.message + false + end end end