mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
parent
d7f80965b1
commit
9b9e265b11
2 changed files with 26 additions and 5 deletions
|
@ -65,11 +65,17 @@ class DangerzoneCore(object):
|
|||
self, ocr_lang: Optional[str], stdout_callback: Optional[Callable] = None
|
||||
) -> None:
|
||||
def convert_doc(document: Document) -> None:
|
||||
self.isolation_provider.convert(
|
||||
document,
|
||||
ocr_lang,
|
||||
stdout_callback,
|
||||
)
|
||||
try:
|
||||
self.isolation_provider.convert(
|
||||
document,
|
||||
ocr_lang,
|
||||
stdout_callback,
|
||||
)
|
||||
except Exception as e:
|
||||
log.exception(
|
||||
f"Unexpected error occurred while converting '{document}'"
|
||||
)
|
||||
document.mark_as_failed()
|
||||
|
||||
max_jobs = self.isolation_provider.get_max_parallel_conversions()
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=max_jobs) as executor:
|
||||
|
|
|
@ -19,6 +19,7 @@ from strip_ansi import strip_ansi
|
|||
from dangerzone.cli import cli_main, display_banner
|
||||
from dangerzone.document import ARCHIVE_SUBDIR, SAFE_EXTENSION
|
||||
from dangerzone.isolation_provider.qubes import is_qubes_native_conversion
|
||||
from dangerzone.util import get_resource_path
|
||||
|
||||
from .conftest import for_each_doc, for_each_external_doc
|
||||
|
||||
|
@ -219,6 +220,20 @@ class TestCliConversion(TestCliBasic):
|
|||
result = self.run_cli([sample_pdf, "--output-filename", output_filename])
|
||||
result.assert_success()
|
||||
|
||||
### Test method for swallowed exception
|
||||
def test_output_filename_same_file_dummy_fails(self) -> None:
|
||||
resource_path = get_resource_path("dummy_document.pdf")
|
||||
# Using the same filename for both input and output should fail.
|
||||
result = self.run_cli(
|
||||
[
|
||||
resource_path,
|
||||
"--output-filename",
|
||||
resource_path,
|
||||
"--unsafe-dummy-conversion",
|
||||
]
|
||||
)
|
||||
result.assert_failure()
|
||||
|
||||
def test_output_filename_new_dir(self, sample_pdf: str) -> None:
|
||||
output_filename = str(Path("fake-directory") / "my-output.pdf")
|
||||
result = self.run_cli([sample_pdf, "--output-filename", output_filename])
|
||||
|
|
Loading…
Reference in a new issue