Files
Bernd Steckmeister dba4b64df8 feat: PYRAMID_PROFILE_DIR-Override fuer Desktop-Testprofile (app_dirs.dart)
DB, auth_log und Media-Cache laufen jetzt ueber appSupportDir(); nur auf
Desktop und nur wenn PYRAMID_PROFILE_DIR gesetzt ist, landet alles in einem
eigenen Profilverzeichnis - fuer Autopilot-Testlogins parallel zur echten
Session. Ohne Variable exakt das bisherige Verhalten. secure_storage/
shared_preferences bewusst nicht umgeleitet (Begruendung im Dateikopf).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 18:55:30 +02:00

32 lines
1.3 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'dart:io';
import 'package:path_provider/path_provider.dart';
/// Basisverzeichnis für alle lokalen App-Daten (pyramid.sqlite, auth_log.txt,
/// Media-Cache).
///
/// Normalfall: das Application-Support-Verzeichnis der Plattform exakt wie
/// bisher, es ändert sich NICHTS.
///
/// Nur auf dem Desktop kann die Umgebungsvariable `PYRAMID_PROFILE_DIR` ein
/// abweichendes Verzeichnis erzwingen. Zweck: Testläufe mit den
/// Autopilot-Testkonten in einem eigenen Profil, parallel zur echten
/// Session desselben Windows-Nutzers (die echte Session sieht die Variable
/// nie und bleibt unberührt). Bewusst NICHT umgeleitet werden
/// shared_preferences und flutter_secure_storage deren Plugins lösen ihre
/// Pfade selbst auf; ein Testprofil teilt sich also den DB-Schlüssel
/// (`db_cipher_key`) und die UI-Prefs mit dem Hauptprofil. Für Tests ist das
/// unkritisch (der Schlüssel wird nur GELESEN, nie überschrieben), echte
/// Zweitkonten bräuchten mehr.
Future<Directory> appSupportDir() async {
final override = Platform.isWindows || Platform.isLinux || Platform.isMacOS
? Platform.environment['PYRAMID_PROFILE_DIR']
: null;
if (override != null && override.trim().isNotEmpty) {
final dir = Directory(override.trim());
await dir.create(recursive: true);
return dir;
}
return getApplicationSupportDirectory();
}