mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-15 12:58:04 +00:00
refactor(constants): single source of truth for data dir (#3368)
* refactor(constants): single source of truth for data dir + merge core/src constants Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(contributing): use named src.constants for data paths, drop core/constants references Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,8 @@ from typing import Tuple
|
||||
|
||||
from src.auth_helpers import owner_filter
|
||||
from core.platform_compat import IS_WINDOWS, find_bash
|
||||
from core.constants import DATA_DIR, internal_api_base
|
||||
from core.constants import internal_api_base
|
||||
from src.constants import DATA_DIR, DEEP_RESEARCH_DIR, TIDY_CALENDAR_STATE_FILE, EMAIL_URGENCY_CACHE_DIR, COOKBOOK_STATE_FILE
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -349,7 +350,7 @@ async def action_tidy_research(owner: str, **kwargs) -> Tuple[str, bool]:
|
||||
try:
|
||||
from pathlib import Path
|
||||
import json as _json
|
||||
research_dir = Path("data/deep_research")
|
||||
research_dir = Path(DEEP_RESEARCH_DIR)
|
||||
if not research_dir.exists():
|
||||
raise TaskNoop("no research directory")
|
||||
files = list(research_dir.glob("*.json"))
|
||||
@@ -387,7 +388,7 @@ async def action_tidy_calendar(owner: str, **kwargs) -> Tuple[str, bool]:
|
||||
from core.database import SessionLocal, CalendarEvent
|
||||
from sqlalchemy import func
|
||||
|
||||
STATE_FILE = Path("data/tidy_calendar_state.json")
|
||||
STATE_FILE = Path(TIDY_CALENDAR_STATE_FILE)
|
||||
last_watermark = None
|
||||
try:
|
||||
if STATE_FILE.exists():
|
||||
@@ -1304,12 +1305,12 @@ async def action_ping_notes(owner: str, **kwargs) -> Tuple[str, bool]:
|
||||
# users' entries (review C4). Legacy path kept as fallback so a
|
||||
# single-user install (empty owner) doesn't lose its history.
|
||||
_owner_slug = "".join(c if (c.isalnum() or c in "-_.@") else "_" for c in (owner or "default"))
|
||||
STATE = _P(f"data/note_pings_{_owner_slug}.json")
|
||||
STATE = _P(DATA_DIR) / f"note_pings_{_owner_slug}.json"
|
||||
STATE.parent.mkdir(parents=True, exist_ok=True)
|
||||
# One-time migration: if legacy global file exists and per-owner file
|
||||
# doesn't, seed from global (entries for OTHER owners still get pruned
|
||||
# on their first run — acceptable, prevents silent loss).
|
||||
_legacy = _P("data/note_pings.json")
|
||||
_legacy = _P(DATA_DIR) / "note_pings.json"
|
||||
if _legacy.exists() and not STATE.exists():
|
||||
try:
|
||||
STATE.write_text(_legacy.read_text(encoding="utf-8"), encoding="utf-8")
|
||||
@@ -1466,8 +1467,8 @@ async def action_check_email_urgency(owner: str, **kwargs) -> Tuple[str, bool]:
|
||||
# notified_uids / urgency counts. Empty owner falls back to a generic
|
||||
# filename for single-user installs (matches prior behaviour).
|
||||
_owner_slug = "".join(c if (c.isalnum() or c in "-_.@") else "_" for c in (owner or "default"))
|
||||
STATE_PATH = _P(f"data/email_urgency_state_{_owner_slug}.json")
|
||||
CACHE_DIR = _P("data/email_urgency_cache")
|
||||
STATE_PATH = _P(DATA_DIR) / f"email_urgency_state_{_owner_slug}.json"
|
||||
CACHE_DIR = _P(EMAIL_URGENCY_CACHE_DIR)
|
||||
CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
||||
STATE_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
AGE_CUTOFF = _dt.utcnow() - _td(days=7)
|
||||
@@ -2043,7 +2044,7 @@ async def action_cookbook_serve(
|
||||
except Exception:
|
||||
end_after_min = 0
|
||||
|
||||
state_path = Path(DATA_DIR) / "cookbook_state.json"
|
||||
state_path = Path(COOKBOOK_STATE_FILE)
|
||||
try:
|
||||
state = json.loads(state_path.read_text(encoding="utf-8")) if state_path.exists() else {}
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user