~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix: resolve filesystem PDF download errors
LearningCircuit06cd5d15d8e9
diff --git a/src/local_deep_research/research_library/services/pdf_storage_manager.py b/src/local_deep_research/research_library/services/pdf_storage_manager.pyindex 272b0c0373..b243506917 100644--- a/src/local_deep_research/research_library/services/pdf_storage_manager.py+++ b/src/local_deep_research/research_library/services/pdf_storage_manager.py@@ -221,6 +221,7 @@ class PDFStorageManager:raise ValueError("Invalid file path")# Write the PDF file with security verification+ # Pass current storage_mode as snapshot since we already validated itfrom ...security.file_write_verifier import write_file_verifiedwrite_file_verified(@@ -230,6 +231,7 @@ class PDFStorageManager:"filesystem","library PDF storage",mode="wb",+ settings_snapshot={"research_library.pdf_storage_mode": self.storage_mode},)return Path(validated_path)diff --git a/src/local_deep_research/security/file_write_verifier.py b/src/local_deep_research/security/file_write_verifier.pyindex 88721a22f8..a247b45ee1 100644--- a/src/local_deep_research/security/file_write_verifier.py+++ b/src/local_deep_research/security/file_write_verifier.py@@ -68,8 +68,13 @@ def write_file_verified(logger.warning(error_msg)raise FileWriteSecurityError(error_msg)- with open(filepath, mode, encoding=encoding) as f:- f.write(content)+ # Don't pass encoding for binary mode+ if "b" in mode:+ with open(filepath, mode) as f:+ f.write(content)+ else:+ with open(filepath, mode, encoding=encoding) as f:+ f.write(content)logger.debug(f"Verified file write: {filepath} (setting: {setting_name}={required_value})"diff --git a/tests/research_library/services/test_pdf_storage_manager.py b/tests/research_library/services/test_pdf_storage_manager.pyindex 464ca3b143..dbee363032 100644--- a/tests/research_library/services/test_pdf_storage_manager.py+++ b/tests/research_library/services/test_pdf_storage_manager.py@@ -307,6 +307,52 @@ class TestPDFStorageManagerUpgradeToPdf:assert result is False+class TestPDFStorageManagerFilesystemWrite:+ """Tests for actual filesystem write operations."""++ def test_saves_to_filesystem_without_encoding_error(self, tmp_path, mock_pdf_content):+ """Should save binary PDF to filesystem without encoding errors.++ Regression test for bug where write_file_verified passed encoding+ argument to binary mode open(), causing ValueError.+ """+ manager = PDFStorageManager(tmp_path, "filesystem")++ # Actually call _save_to_filesystem (not mocked)+ result_path = manager._save_to_filesystem(+ mock_pdf_content,+ "test_document.pdf",+ url="https://example.com/paper.pdf",+ resource_id=123,+ )++ # Verify file was created+ assert result_path.exists()+ assert result_path.suffix == ".pdf"++ # Verify content matches+ saved_content = result_path.read_bytes()+ assert saved_content == mock_pdf_content++ def test_filesystem_write_uses_settings_snapshot(self, tmp_path, mock_pdf_content):+ """Should pass settings_snapshot to write_file_verified.++ Regression test for bug where settings couldn't be found because+ no settings_snapshot was passed to write_file_verified.+ """+ # Create manager with filesystem mode+ manager = PDFStorageManager(tmp_path, "filesystem")++ # This should work without raising FileWriteSecurityError+ # because the settings_snapshot is now passed correctly+ result_path = manager._save_to_filesystem(+ mock_pdf_content,+ "snapshot_test.pdf",+ )++ assert result_path.exists()++class TestPDFStorageManagerGenerateFilename:"""Tests for _generate_filename method."""