v0.4.3 — DB in AppData/Local/Speiseplan statt User-Home

- speiseplan.db jetzt in %LOCALAPPDATA%/Speiseplan/
- Uninstaller räumt AppData-Ordner auf
This commit is contained in:
clawd
2026-02-20 11:02:07 +00:00
parent 3b8db152b1
commit 9c6833957f
2 changed files with 10 additions and 5 deletions

View File

@@ -75,7 +75,7 @@ Section "Uninstall"
; Datenbank löschen
MessageBox MB_YESNO "Sollen die gespeicherten Daten (Speisepläne, Produkte) ebenfalls gelöscht werden?" IDYES deletedata IDNO skipdata
deletedata:
Delete "$PROFILE\speiseplan.db"
RMDir /r "$LOCALAPPDATA\Speiseplan"
skipdata:
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Speiseplan"

13
db.go
View File

@@ -13,13 +13,18 @@ var db *sqlx.DB
// InitDatabase initialisiert die SQLite-Datenbank
func InitDatabase() error {
// DB-Datei im User-Home-Verzeichnis
homeDir, err := os.UserHomeDir()
// DB-Datei in AppData/Local/Speiseplan
configDir, err := os.UserConfigDir()
if err != nil {
return fmt.Errorf("failed to get user home directory: %w", err)
return fmt.Errorf("failed to get config directory: %w", err)
}
dbPath := filepath.Join(homeDir, "speiseplan.db")
appDir := filepath.Join(configDir, "Speiseplan")
if err := os.MkdirAll(appDir, 0755); err != nil {
return fmt.Errorf("failed to create app directory: %w", err)
}
dbPath := filepath.Join(appDir, "speiseplan.db")
// Verbindung zur Datenbank herstellen
database, err := sqlx.Open("sqlite", dbPath)