058180ea1a
Vía rápida DB→Xandikos para operaciones masivas: genera todos los vCards de agenda desde DuckDB a un tmpdir, rsync de golpe al working tree de la colección en magnus (excluyendo .git/.xandikos), UN solo git commit, y 1 PROPFIND para capturar todos los etags en batch. ~0.5s vs ~6min del push HTTP (que hace N PUTs + N PROPFINDs + N commits). El push HTTP push_all_dav se mantiene como fallback (y para CalDAV). Config DAV_BULK_SSH_HOST/REMOTE_DIR. 22 tests verdes.
72 lines
2.8 KiB
Python
72 lines
2.8 KiB
Python
"""Configuración del service osint_db.
|
|
|
|
Valores por defecto del PC de enmanuel; todo es sobreescribible por CLI
|
|
(--vault, --db, --port) o construyendo un Config a mano en los tests. La
|
|
configuración DAV (base_url, colecciones, secreto en pass) es la misma que usan
|
|
los tools del proyecto (projects/osint/tools/sync_dav_to_osint.py).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from dataclasses import dataclass, field
|
|
|
|
# Directorio raíz de la app (padre de server/).
|
|
APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
DEFAULT_VAULT = os.path.expanduser("~/Obsidian/osint")
|
|
DEFAULT_DB = os.path.join(APP_DIR, "data", "osint.duckdb")
|
|
DEFAULT_PORT = 8771
|
|
|
|
# Configuración Xandikos (espejo de projects/osint/tools/sync_dav_to_osint.py).
|
|
DAV_BASE = "https://dav-eedeb681c4ab89ab8e444ac9.organic-machine.com"
|
|
DAV_USER = "enmanuel"
|
|
DAV_CONTACTS_COLLECTION = "/enmanuel/contacts/addressbook/"
|
|
DAV_CALENDAR_HOME = "/enmanuel/calendars/"
|
|
PASS_SECRET = "dav/xandikos-enmanuel"
|
|
|
|
# Vía rápida de push masivo por disco (POST /api/push/dav-bulk): Xandikos sirve
|
|
# cada colección desde el working tree de un repo git en el host que la aloja, y
|
|
# calcula el ctag desde el HEAD. Escribiendo los .vcf directos al working tree y
|
|
# haciendo UN solo commit, Xandikos ve el cambio en el siguiente request (nuevo
|
|
# ctag -> DAVx5 lo detecta), evitando los N PUT + N PROPFIND + N commit del push
|
|
# HTTP. Solo aplica a la colección CardDAV por defecto (la del addressbook).
|
|
#
|
|
# - DAV_BULK_SSH_HOST: alias SSH (~/.ssh/config) del host de Xandikos (magnus).
|
|
# - DAV_BULK_REMOTE_DIR: working tree de la colección CardDAV por defecto en el
|
|
# host. Debe terminar en '/'. Es un repo git que Xandikos sirve.
|
|
DAV_BULK_SSH_HOST = "magnus"
|
|
DAV_BULK_REMOTE_DIR = "/srv/xandikos/data/enmanuel/contacts/addressbook/"
|
|
|
|
# Carpetas del vault que mapean a tablas maestras de entidades.
|
|
# (carpeta del vault, tipo de frontmatter, tabla destino)
|
|
ENTITY_FOLDERS = (
|
|
("personas", "persona", "persons"),
|
|
("organizaciones", "organizacion", "organizations"),
|
|
("dominios", "dominio", "domains"),
|
|
("casos", "caso", "cases"),
|
|
("lugares", "lugar", "places"),
|
|
)
|
|
|
|
# Marker de los bloques sentinel que este service gestiona en notas del vault.
|
|
SENTINEL_MARKER = "osintdb"
|
|
|
|
|
|
@dataclass
|
|
class Config:
|
|
"""Configuración efectiva del service (inyectable en tests)."""
|
|
|
|
vault_dir: str = DEFAULT_VAULT
|
|
db_path: str = DEFAULT_DB
|
|
port: int = DEFAULT_PORT
|
|
host: str = "127.0.0.1"
|
|
dav_base: str = DAV_BASE
|
|
dav_user: str = DAV_USER
|
|
dav_contacts_collection: str = DAV_CONTACTS_COLLECTION
|
|
dav_calendar_home: str = DAV_CALENDAR_HOME
|
|
pass_secret: str = PASS_SECRET
|
|
entity_folders: tuple = field(default=ENTITY_FOLDERS)
|
|
# Push masivo por disco (POST /api/push/dav-bulk).
|
|
dav_bulk_ssh_host: str = DAV_BULK_SSH_HOST
|
|
dav_bulk_remote_dir: str = DAV_BULK_REMOTE_DIR
|