mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-18 22:08:14 +00:00
Fix: use float parsing for importer manifest records with a passphrase
This commit is contained in:
1 parent
41498113d3
commit
c6f83cc1a0
2 files changed
+40
-1
No files matched your search
@@ -66,7 +66,7 @@ def iter_manifest_records(path: Path) -> Generator[dict, None, None]:
|
||||
"""Yield records one at a time from a manifest JSON array via ijson."""
|
||||
try:
|
||||
with path.open("rb") as f:
|
||||
yield from ijson.items(f, "item")
|
||||
yield from ijson.items(f, "item", use_float=True)
|
||||
except ijson.JSONError as e:
|
||||
raise CommandError(f"Failed to parse manifest file {path}: {e}") from e
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ from documents.settings import EXPORTER_FILE_NAME
|
||||
from documents.settings import EXPORTER_SHARE_LINK_BUNDLE_NAME
|
||||
from documents.settings import EXPORTER_THUMBNAIL_NAME
|
||||
from documents.tests.utils import SampleDirMixin
|
||||
from paperless.models import ApplicationConfiguration
|
||||
from paperless_mail.models import MailAccount
|
||||
from paperless_testing.assertions import FileSystemAssertsMixin
|
||||
from paperless_testing.dirs import DirectoriesMixin
|
||||
@@ -1402,6 +1403,44 @@ class TestCryptExportImport(
|
||||
social_token = SocialToken.objects.first()
|
||||
self.assertIsNotNone(social_token)
|
||||
|
||||
def test_import_passphrase_with_float_field(self) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- An application configuration with a float field set
|
||||
WHEN:
|
||||
- Export and import are run with a passphrase
|
||||
THEN:
|
||||
- The import succeeds and the float value is preserved
|
||||
"""
|
||||
config = ApplicationConfiguration.objects.first()
|
||||
config.rotate_pages_threshold = 12.5
|
||||
config.save()
|
||||
|
||||
call_command(
|
||||
"document_exporter",
|
||||
"--no-progress-bar",
|
||||
"--passphrase",
|
||||
"securepassword",
|
||||
self.target,
|
||||
skip_checks=True,
|
||||
)
|
||||
|
||||
ApplicationConfiguration.objects.all().delete()
|
||||
|
||||
call_command(
|
||||
"document_importer",
|
||||
"--no-progress-bar",
|
||||
"--passphrase",
|
||||
"securepassword",
|
||||
self.target,
|
||||
skip_checks=True,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
ApplicationConfiguration.objects.first().rotate_pages_threshold,
|
||||
12.5,
|
||||
)
|
||||
|
||||
def test_import_crypt_no_passphrase(self) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
|
||||
Reference in new issue
Block a user