feat: Add NSIS installer target and persistent SQLite storage

- Add NSIS installer as default target (--target nsis)
- Keep portable option available (--target portable)
- Store SQLite database in %APPDATA%\Meeting-Assistant for persistence
- Portable temp folder cleanup no longer affects SQLite data
- Update build-client.bat with --target parameter support
- Update DEPLOYMENT.md with new options and comparisons

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-18 08:13:32 +08:00
parent bc37a5392a
commit 08cffbb74a
4 changed files with 113 additions and 17 deletions

View File

@@ -15,6 +15,30 @@ def get_base_dir() -> str:
return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def get_app_data_dir() -> str:
"""Get persistent app data directory for storing user data.
This directory persists across application restarts, unlike temp folders
used by portable executables.
Returns:
Windows: %APPDATA%/Meeting-Assistant
macOS: ~/Library/Application Support/Meeting-Assistant
Linux: ~/.config/meeting-assistant
"""
if sys.platform == "win32":
# Windows: Use APPDATA
base = os.environ.get("APPDATA", os.path.expanduser("~"))
return os.path.join(base, "Meeting-Assistant")
elif sys.platform == "darwin":
# macOS: Use Application Support
return os.path.expanduser("~/Library/Application Support/Meeting-Assistant")
else:
# Linux: Use XDG config or fallback to ~/.config
xdg_config = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
return os.path.join(xdg_config, "meeting-assistant")
class Settings:
# Server Configuration
BACKEND_HOST: str = os.getenv("BACKEND_HOST", "0.0.0.0")
@@ -95,15 +119,27 @@ class Settings:
def get_sqlite_path(self, base_dir: str | None = None) -> str:
"""Get SQLite database file path, resolving relative paths.
For packaged executables (frozen), uses persistent app data directory
to survive portable exe cleanup. For development, uses relative path.
Args:
base_dir: Base directory for relative paths. If None, uses get_base_dir()
which supports frozen executables.
base_dir: Base directory for relative paths. If None, auto-detects.
"""
# If absolute path specified, use it directly
if self.SQLITE_PATH and os.path.isabs(self.SQLITE_PATH):
return self.SQLITE_PATH
# For frozen executables, use persistent app data directory
# This ensures SQLite data survives portable exe temp cleanup
if getattr(sys, "frozen", False):
app_data = get_app_data_dir()
db_name = os.path.basename(self.SQLITE_PATH) if self.SQLITE_PATH else "meeting.db"
return os.path.join(app_data, "data", db_name)
# For development, use relative path from base_dir
if base_dir is None:
base_dir = get_base_dir()
if self.SQLITE_PATH:
if os.path.isabs(self.SQLITE_PATH):
return self.SQLITE_PATH
return os.path.join(base_dir, self.SQLITE_PATH)
return os.path.join(base_dir, "data", "meeting.db")