Compare commits

..

2 Commits

Author SHA1 Message Date
shamoon
0b265aadc6 Add error handling w retty when opening index 2025-12-17 09:14:26 -08:00
shamoon
84511d07cd Add test to mock issue 2025-12-17 09:07:22 -08:00
6 changed files with 86 additions and 33 deletions

View File

@@ -496,7 +496,7 @@
<context context-type="sourcefile">src/app/components/manage/mail/mail.component.html</context>
<context context-type="linenumber">4</context>
</context-group>
<target state="translated">Beheer e-mailaccounts en regels voor het automatisch importeren van documenten.</target>
<target state="translated">E-mailaccounts en regels voor automatisch importeren van documenten beheren.</target>
</trans-unit>
<trans-unit id="2258659358902319601" datatype="html">
<source>Workflows give you more control over the document pipeline.</source>
@@ -740,7 +740,7 @@
<context context-type="sourcefile">src/app/components/admin/logs/logs.component.html</context>
<context context-type="linenumber">4</context>
</context-group>
<target state="translated">Bekijk de logbestanden van de applicatie en voor het ophalen van e-mails.</target>
<target state="translated">Bekijk de logbestanden voor de applicatie en voor het ophalen van e-mails.</target>
</trans-unit>
<trans-unit id="8461842260159597706" datatype="html">
<source>Show</source>
@@ -764,7 +764,7 @@
<context context-type="sourcefile">src/app/components/admin/logs/logs.component.html</context>
<context context-type="linenumber">17</context>
</context-group>
<target state="translated">regels</target>
<target state="needs-translation">lines</target>
</trans-unit>
<trans-unit id="8838884664569764142" datatype="html">
<source>Auto refresh</source>
@@ -892,7 +892,7 @@
<context context-type="sourcefile">src/app/components/admin/logs/logs.component.html</context>
<context context-type="linenumber">62</context>
</context-group>
<target state="translated">Spring naar beneden</target>
<target state="needs-translation">Jump to bottom</target>
</trans-unit>
<trans-unit id="1255048712725285892" datatype="html">
<source>Options to customize appearance, notifications and more. Settings apply to the &lt;strong&gt;current user only&lt;/strong&gt;.</source>
@@ -1416,7 +1416,7 @@
<context context-type="sourcefile">src/app/components/admin/settings/settings.component.html</context>
<context context-type="linenumber">266,268</context>
</context-group>
<target state="translated"> Instellingen zijn van toepassing op dit account voor objecten (tags, mailregels, enz., maar niet op documenten) die via de webinterface zijn aangemaakt. </target>
<target state="needs-translation"> Settings apply to this user account for objects (Tags, Mail Rules, etc. but not documents) created via the web UI. </target>
</trans-unit>
<trans-unit id="4292903881380648974" datatype="html">
<source>Default Owner</source>
@@ -1956,7 +1956,7 @@
<context context-type="sourcefile">src/app/components/admin/tasks/tasks.component.html</context>
<context context-type="linenumber">64</context>
</context-group>
<target state="translated">Resultaat</target>
<target state="translated">Resultaten</target>
</trans-unit>
<trans-unit id="314315645942131479" datatype="html" approved="yes">
<source>Info</source>
@@ -3952,7 +3952,7 @@
<context context-type="sourcefile">src/app/components/common/dates-dropdown/dates-dropdown.component.ts</context>
<context context-type="linenumber">121</context>
</context-group>
<target state="translated">Vorige week</target>
<target state="needs-translation">Previous week</target>
</trans-unit>
<trans-unit id="8586908745456864217" datatype="html">
<source>Previous month</source>
@@ -3960,7 +3960,7 @@
<context context-type="sourcefile">src/app/components/common/dates-dropdown/dates-dropdown.component.ts</context>
<context context-type="linenumber">135</context>
</context-group>
<target state="translated">Vorige maand</target>
<target state="needs-translation">Previous month</target>
</trans-unit>
<trans-unit id="357608474534295480" datatype="html">
<source>Previous quarter</source>
@@ -3968,7 +3968,7 @@
<context context-type="sourcefile">src/app/components/common/dates-dropdown/dates-dropdown.component.ts</context>
<context context-type="linenumber">141</context>
</context-group>
<target state="translated">Vorig kwartaal</target>
<target state="needs-translation">Previous quarter</target>
</trans-unit>
<trans-unit id="100513227838842152" datatype="html">
<source>Previous year</source>
@@ -3976,7 +3976,7 @@
<context context-type="sourcefile">src/app/components/common/dates-dropdown/dates-dropdown.component.ts</context>
<context context-type="linenumber">155</context>
</context-group>
<target state="translated">Vorig jaar</target>
<target state="needs-translation">Previous year</target>
</trans-unit>
<trans-unit id="8743659855412792665" datatype="html" approved="yes">
<source>Matching algorithm</source>
@@ -4700,7 +4700,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.ts</context>
<context context-type="linenumber">118</context>
</context-group>
<target state="translated">Geen titel van deze regel toewijzen</target>
<target state="translated">Titel van deze regel niet gebruiken</target>
</trans-unit>
<trans-unit id="1568902914205618549" datatype="html">
<source>Do not assign a correspondent</source>
@@ -4724,7 +4724,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.ts</context>
<context context-type="linenumber">133</context>
</context-group>
<target state="translated">Gebruik de naam (of e-mailadres indien niet beschikbaar)</target>
<target state="translated">Gebruik de naam (of het e-mailadres indien niet beschikbaar)</target>
</trans-unit>
<trans-unit id="1258862217749148424" datatype="html">
<source>Use correspondent selected below</source>
@@ -5276,7 +5276,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html</context>
<context context-type="linenumber">183</context>
</context-group>
<target state="translated">Geavanceerde filters</target>
<target state="needs-translation">Advanced Filters</target>
</trans-unit>
<trans-unit id="910026778839409110" datatype="html">
<source>Add filter</source>
@@ -5284,7 +5284,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html</context>
<context context-type="linenumber">190</context>
</context-group>
<target state="translated">Filter toevoegen</target>
<target state="needs-translation">Add filter</target>
</trans-unit>
<trans-unit id="5671193617280178107" datatype="html">
<source>No advanced workflow filters defined.</source>
@@ -5292,7 +5292,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html</context>
<context context-type="linenumber">195</context>
</context-group>
<target state="translated">Er zijn geen geavanceerde workflow filters gedefinieerd.</target>
<target state="needs-translation">No advanced workflow filters defined.</target>
</trans-unit>
<trans-unit id="6892734625735572404" datatype="html">
<source> Complete the custom field query configuration. </source>
@@ -5300,7 +5300,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html</context>
<context context-type="linenumber">224,226</context>
</context-group>
<target state="translated"> Voltooi de query configuratie van het aangepaste veld. </target>
<target state="needs-translation"> Complete the custom field query configuration. </target>
</trans-unit>
<trans-unit id="6417103744331194518" datatype="html">
<source>Action type</source>
@@ -5680,7 +5680,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts</context>
<context context-type="linenumber">203</context>
</context-group>
<target state="translated">Heeft een van deze labels</target>
<target state="needs-translation">Has any of these tags</target>
</trans-unit>
<trans-unit id="4166903555074156852" datatype="html">
<source>Has all of these tags</source>
@@ -5688,7 +5688,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts</context>
<context context-type="linenumber">210</context>
</context-group>
<target state="translated">Heeft al deze labels</target>
<target state="needs-translation">Has all of these tags</target>
</trans-unit>
<trans-unit id="6624363795312783141" datatype="html">
<source>Does not have these tags</source>
@@ -5696,7 +5696,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts</context>
<context context-type="linenumber">217</context>
</context-group>
<target state="translated">Geen van deze labels</target>
<target state="needs-translation">Does not have these tags</target>
</trans-unit>
<trans-unit id="5281365940563983618" datatype="html">
<source>Has correspondent</source>
@@ -5712,7 +5712,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts</context>
<context context-type="linenumber">232</context>
</context-group>
<target state="translated">Geen van deze correspondenten</target>
<target state="needs-translation">Does not have correspondents</target>
</trans-unit>
<trans-unit id="4806713133917046341" datatype="html">
<source>Has document type</source>
@@ -5728,7 +5728,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts</context>
<context context-type="linenumber">248</context>
</context-group>
<target state="translated">Geen van deze documenttypes</target>
<target state="needs-translation">Does not have document types</target>
</trans-unit>
<trans-unit id="4277260190522078330" datatype="html">
<source>Has storage path</source>
@@ -5736,7 +5736,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts</context>
<context context-type="linenumber">256</context>
</context-group>
<target state="translated">Heeft opslagpad</target>
<target state="needs-translation">Has storage path</target>
</trans-unit>
<trans-unit id="6070943364927280151" datatype="html">
<source>Does not have storage paths</source>
@@ -5744,7 +5744,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts</context>
<context context-type="linenumber">264</context>
</context-group>
<target state="translated">Geen van deze opslagpaden</target>
<target state="needs-translation">Does not have storage paths</target>
</trans-unit>
<trans-unit id="6250799006816371860" datatype="html">
<source>Matches custom field query</source>
@@ -5752,7 +5752,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts</context>
<context context-type="linenumber">272</context>
</context-group>
<target state="translated">Komt overeen met aangepast veld query</target>
<target state="needs-translation">Matches custom field query</target>
</trans-unit>
<trans-unit id="3138206142174978019" datatype="html">
<source>Create new workflow</source>
@@ -8735,7 +8735,7 @@
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
<context context-type="linenumber">18</context>
</context-group>
<target state="translated">Selecteer:</target>
<target state="needs-translation">Select:</target>
</trans-unit>
<trans-unit id="6252070156626006029" datatype="html">
<source>None</source>

View File

@@ -5736,7 +5736,7 @@
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts</context>
<context context-type="linenumber">256</context>
</context-group>
<target state="translated">Имеет путь к хранилищу</target>
<target state="needs-translation">Has storage path</target>
</trans-unit>
<trans-unit id="6070943364927280151" datatype="html">
<source>Does not have storage paths</source>

View File

@@ -10,6 +10,7 @@ from datetime import time
from datetime import timedelta
from datetime import timezone
from shutil import rmtree
from time import sleep
from typing import TYPE_CHECKING
from typing import Literal
@@ -32,6 +33,7 @@ from whoosh.highlight import HtmlFormatter
from whoosh.idsets import BitSet
from whoosh.idsets import DocIdSet
from whoosh.index import FileIndex
from whoosh.index import LockError
from whoosh.index import create_in
from whoosh.index import exists_in
from whoosh.index import open_dir
@@ -97,11 +99,33 @@ def get_schema() -> Schema:
def open_index(*, recreate=False) -> FileIndex:
try:
if exists_in(settings.INDEX_DIR) and not recreate:
return open_dir(settings.INDEX_DIR, schema=get_schema())
except Exception:
logger.exception("Error while opening the index, recreating.")
transient_exceptions = (FileNotFoundError, LockError)
max_retries = 3
retry_delay = 0.1
for attempt in range(max_retries + 1):
try:
if exists_in(settings.INDEX_DIR) and not recreate:
return open_dir(settings.INDEX_DIR, schema=get_schema())
break
except transient_exceptions as exc:
is_last_attempt = attempt == max_retries or recreate
if is_last_attempt:
logger.exception(
"Error while opening the index after retries, recreating.",
)
break
logger.warning(
"Transient error while opening the index (attempt %s/%s): %s. Retrying.",
attempt + 1,
max_retries + 1,
exc,
)
sleep(retry_delay)
except Exception:
logger.exception("Error while opening the index, recreating.")
break
# create_in doesn't handle corrupted indexes very well, remove the directory entirely first
if settings.INDEX_DIR.is_dir():

View File

@@ -1,6 +1,7 @@
from datetime import datetime
from unittest import mock
from django.conf import settings
from django.contrib.auth.models import User
from django.test import SimpleTestCase
from django.test import TestCase
@@ -251,3 +252,31 @@ class TestRewriteNaturalDateKeywords(SimpleTestCase):
result = self._rewrite_with_now("added:today", fixed_now)
# Should convert to UTC properly
self.assertIn("added:[20250719", result)
class TestIndexResilience(DirectoriesMixin, SimpleTestCase):
def test_transient_missing_segment_does_not_force_recreate(self):
file_marker = settings.INDEX_DIR / "file_marker.txt"
file_marker.write_text("keep")
expected_index = object()
with (
mock.patch("documents.index.exists_in", return_value=True),
mock.patch(
"documents.index.open_dir",
side_effect=[FileNotFoundError("missing"), expected_index],
) as mock_open_dir,
mock.patch(
"documents.index.create_in",
) as mock_create_in,
mock.patch(
"documents.index.rmtree",
) as mock_rmtree,
):
ix = index.open_index()
self.assertIs(ix, expected_index)
self.assertGreaterEqual(mock_open_dir.call_count, 2)
mock_rmtree.assert_not_called()
mock_create_in.assert_not_called()
self.assertEqual(file_marker.read_text(), "keep")

View File

@@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: paperless-ngx\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-12-12 17:41+0000\n"
"PO-Revision-Date: 2025-12-13 12:13\n"
"PO-Revision-Date: 2025-12-12 17:44\n"
"Last-Translator: \n"
"Language-Team: Dutch\n"
"Language: nl_NL\n"

View File

@@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: paperless-ngx\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-12-12 17:41+0000\n"
"PO-Revision-Date: 2025-12-17 00:36\n"
"PO-Revision-Date: 2025-12-12 17:44\n"
"Last-Translator: \n"
"Language-Team: Russian\n"
"Language: ru_RU\n"