refactor(1): detection App->Core + AppPaths (VD_DATA_DIR isolation for deterministic E2E)
This commit is contained in:
parent
1aab8729fa
commit
9eb988440f
5 changed files with 29 additions and 7 deletions
14
VideoDownloader.App/AppPaths.cs
Normal file
14
VideoDownloader.App/AppPaths.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
namespace VideoDownloader.App;
|
||||
|
||||
/// <summary>
|
||||
/// 앱 데이터 디렉터리 결정. 기본 %AppData%/VideoDownloader.
|
||||
/// 환경변수 VD_DATA_DIR 로 오버라이드 — E2E 테스트가 실사용자 프로필/설정/세션과
|
||||
/// 격리된 임시 디렉터리에서 실행되도록 한다(결정적 테스트를 위한 공식 후크).
|
||||
/// </summary>
|
||||
public static class AppPaths
|
||||
{
|
||||
public static string DataDir =>
|
||||
Environment.GetEnvironmentVariable("VD_DATA_DIR") is { Length: > 0 } env
|
||||
? env
|
||||
: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VideoDownloader");
|
||||
}
|
||||
|
|
@ -7,8 +7,7 @@ namespace VideoDownloader.App.Browser;
|
|||
/// 손상 파일은 백업 후 빈 목록을 반환(다음 저장이 원본을 덮어쓰는 데이터 손실 방지).</summary>
|
||||
public static class BrowserStore
|
||||
{
|
||||
private static string Dir => Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VideoDownloader");
|
||||
private static string Dir => AppPaths.DataDir;
|
||||
private static string BookmarksPath => Path.Combine(Dir, "bookmarks.json");
|
||||
private static string HistoryPath => Path.Combine(Dir, "history.json");
|
||||
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ namespace VideoDownloader.App.Core;
|
|||
/// <summary>%AppData%/VideoDownloader/config.json 으로 설정 영속화</summary>
|
||||
public static class ConfigStore
|
||||
{
|
||||
private static string Dir => Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VideoDownloader");
|
||||
private static string Dir => AppPaths.DataDir;
|
||||
private static string FilePath => Path.Combine(Dir, "config.json");
|
||||
|
||||
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
||||
|
|
|
|||
|
|
@ -145,9 +145,8 @@ public partial class MainWindow : Window
|
|||
[DllImport("dwmapi.dll")]
|
||||
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attribute, ref int pvAttribute, int cbAttribute);
|
||||
|
||||
/// <summary>WebView2 영속 프로필 경로. 쿠키·세션·localStorage·캐시가 여기 보존되어 앱/빌드 재시작에도 유지.</summary>
|
||||
internal static string AppDataDir => Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VideoDownloader");
|
||||
/// <summary>앱 데이터 디렉터리(AppPaths.DataDir — VD_DATA_DIR 오버라이드 지원).</summary>
|
||||
internal static string AppDataDir => AppPaths.DataDir;
|
||||
|
||||
internal static string ProfileFolder => Path.Combine(AppDataDir, "webview");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue