# SecondBrain — (c) 2026 Atlas Corporation. All Rights Reserved. Proprietary; see LICENSE. """Connector: local files & folders (notes, code, docs).""" import os from .base import Connector, Field, register, _brain @register class FilesystemConnector(Connector): id = "files" name = "Files & folders" blurb = "Index a local directory of notes / code / docs (60+ text types)." fields = [Field("path", "Directory to index", default="~/notes")] def test(self, cfg): p = os.path.expanduser(cfg["path"]) if not os.path.isdir(p): raise RuntimeError(f"not a directory: {p}") return f"dir ok: {p}" def sync(self, cfg): brain = _brain() p = os.path.expanduser(cfg["path"]) conn = brain.db(); before = conn.execute("select count(*) from chunks").fetchone()[0]; conn.close() brain.ingest_files(p) # stages directly through scrub conn = brain.db(); after = conn.execute("select count(*) from chunks").fetchone()[0]; conn.close() return after - before