Files
PM-pinou 0b6672781f feat(settings): migrate db.sqlite3 to APPDATA dir, extract shared appdata.py
Migrate database path from project-local db.sqlite3 to %%APPDATA%%/TianXuan/ so data persists across updates.
- tianxuan/settings.py: DB path to APPDATA
- tianxuan/wsgi.py: use settings.DATABASES path instead of hardcoded db.sqlite3
- analysis/appdata.py: extract shared APPDATA path resolution
- analysis/session_store.py: use appdata.py for session store path
- analysis/views.py: use appdata.py for view paths

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-20 14:14:07 +08:00

17 lines
479 B
Python

"""跨模块共享的 %APPDATA% 路径工具"""
import os
from pathlib import Path
def get_appdata_dir() -> Path:
"""返回 %APPDATA%/TianXuan 目录路径(不保证存在)"""
appdata = os.environ.get('APPDATA', str(Path.home() / '.tianxuan'))
return Path(appdata) / 'TianXuan'
def ensure_appdata_dir() -> Path:
"""返回 %APPDATA%/TianXuan 目录路径(自动创建)"""
d = get_appdata_dir()
d.mkdir(parents=True, exist_ok=True)
return d