~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
refactor(config): extract _ensure_dir helper in paths.py (DRY) (#4714)
LearningCircuitd32343ea22f2
diff --git a/src/local_deep_research/config/paths.py b/src/local_deep_research/config/paths.pyindex d95c627119..627d2c006d 100644--- a/src/local_deep_research/config/paths.py+++ b/src/local_deep_research/config/paths.py@@ -46,6 +46,25 @@ def get_data_directory() -> Path:return data_dir+def _ensure_dir(subdir: str, label: str | None = None) -> Path:+ """Create (if needed) and return ``<data_dir>/<subdir>``.++ Args:+ subdir: Path segment below the data directory. May be multi-segment+ (e.g. ``"encrypted_databases/backups"``).+ label: If provided, emit a debug log ``"Using {label} directory:+ {path}"``. ``None`` suppresses logging.++ Returns:+ The ensured directory path.+ """+ path = get_data_directory() / subdir+ path.mkdir(parents=True, exist_ok=True)+ if label is not None:+ logger.debug(f"Using {label} directory: {path}")+ return path++def get_research_outputs_directory() -> Path:"""Get the directory for storing research outputs (reports, etc.).@@ -53,13 +72,7 @@ def get_research_outputs_directory() -> Path:Returns:Path to research outputs directory"""- # Use subdirectory of main data directory- data_dir = get_data_directory()- outputs_dir = data_dir / "research_outputs"- outputs_dir.mkdir(parents=True, exist_ok=True)-- logger.debug(f"Using research outputs directory: {outputs_dir}")- return outputs_dir+ return _ensure_dir("research_outputs", label="research outputs")def get_journal_data_directory() -> Path:@@ -72,10 +85,7 @@ def get_journal_data_directory() -> Path:Returns:Path to journal data directory"""- data_dir = get_data_directory()- journal_dir = data_dir / "journal_data"- journal_dir.mkdir(parents=True, exist_ok=True)- return journal_dir+ return _ensure_dir("journal_data")def get_cache_directory() -> Path:@@ -85,13 +95,7 @@ def get_cache_directory() -> Path:Returns:Path to cache directory"""- # Use subdirectory of main data directory- data_dir = get_data_directory()- cache_dir = data_dir / "cache"- cache_dir.mkdir(parents=True, exist_ok=True)-- logger.debug(f"Using cache directory: {cache_dir}")- return cache_dir+ return _ensure_dir("cache", label="cache")def get_logs_directory() -> Path:@@ -101,13 +105,7 @@ def get_logs_directory() -> Path:Returns:Path to logs directory"""- # Use subdirectory of main data directory- data_dir = get_data_directory()- logs_dir = data_dir / "logs"- logs_dir.mkdir(parents=True, exist_ok=True)-- logger.debug(f"Using logs directory: {logs_dir}")- return logs_dir+ return _ensure_dir("logs", label="logs")def get_encrypted_database_path() -> Path:@@ -116,10 +114,7 @@ def get_encrypted_database_path() -> Path:Returns:Path to the encrypted databases directory"""- data_dir = get_data_directory()- encrypted_db_path = data_dir / "encrypted_databases"- encrypted_db_path.mkdir(parents=True, exist_ok=True)- return encrypted_db_path+ return _ensure_dir("encrypted_databases")def get_user_database_filename(username: str) -> str:@@ -143,13 +138,7 @@ def get_library_directory() -> Path:Returns:Path to library directory"""- # Use subdirectory of main data directory- data_dir = get_data_directory()- library_dir = data_dir / "library"- library_dir.mkdir(parents=True, exist_ok=True)-- logger.debug(f"Using library directory: {library_dir}")- return library_dir+ return _ensure_dir("library", label="library")def get_config_directory() -> Path:@@ -159,13 +148,7 @@ def get_config_directory() -> Path:Returns:Path to config directory"""- # Use subdirectory of main data directory- data_dir = get_data_directory()- config_dir = data_dir / "config"- config_dir.mkdir(parents=True, exist_ok=True)-- logger.debug(f"Using config directory: {config_dir}")- return config_dir+ return _ensure_dir("config", label="config")def get_models_directory() -> Path:@@ -175,21 +158,12 @@ def get_models_directory() -> Path:Returns:Path to models directory"""- # Use subdirectory of main data directory- data_dir = get_data_directory()- models_dir = data_dir / "models"- models_dir.mkdir(parents=True, exist_ok=True)-- logger.debug(f"Using models directory: {models_dir}")- return models_dir+ return _ensure_dir("models", label="models")def get_backup_directory() -> Path:"""Get the base backup directory for all users."""- data_dir = get_data_directory()- backup_dir = data_dir / "encrypted_databases" / "backups"- backup_dir.mkdir(parents=True, exist_ok=True)- return backup_dir+ return _ensure_dir("encrypted_databases/backups")def get_user_backup_directory(username: str) -> Path: