refactor(3): VideoDownloader.Browser library - tabs/find/search-engine/zoom/bookmark-history stores extracted from App (66 GREEN)

This commit is contained in:
Yun Chan 2026-08-15 15:02:23 +09:00
parent 6df9f81b4a
commit e8ec1350b3
20 changed files with 63 additions and 31 deletions

View file

@ -1,38 +0,0 @@
using System.IO;
using System.Text.Json;
namespace VideoDownloader.App.Browser.Tabs;
/// <summary>세션 JSON 저장소(T1-10). 종료 시 탭 URL 저장, 시작 시 복원.</summary>
public static class TabSessionStore
{
public static void Save(string path, SessionSnapshot snap)
{
try
{
var dir = Path.GetDirectoryName(path);
if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir);
var tmp = path + ".tmp";
File.WriteAllText(tmp, JsonSerializer.Serialize(snap));
File.Move(tmp, path, overwrite: true);
}
catch { }
}
public static SessionSnapshot? Load(string path)
{
try
{
if (!File.Exists(path)) return null;
var snap = JsonSerializer.Deserialize<SessionSnapshot>(File.ReadAllText(path));
if (snap == null || snap.Urls == null || snap.Urls.Count == 0) return null;
var pinned = snap.Pinned ?? new List<bool>();
while (pinned.Count < snap.Urls.Count) pinned.Add(false);
return snap with { Pinned = pinned };
}
catch
{
return null;
}
}
}