T3-11/14/15 + M2 잔여: 권한 정책 UI(PermissionGate/PermissionRequested 다이얼로그+SavesInProfile), 추적 방지(TrackerBlocklist/WebResourceRequested 차단+실드 배지·팝업), 주소창 진행 바+파라미터 제거 복사(UrlCleaner/NavProgressTracker), U5 완료 알림(Mobile.Core 감지기+Plugin.LocalNotification), 재생중 ongoing 미디어 알림, 썸네일/해상도 API(Thumbnailer 사이드카 캐시+/thumb)+라이브러리 그리드, 외부망 안내(ConnectionTroubleshoot). 147 tests GREEN
This commit is contained in:
parent
27c91c04dd
commit
46c6c321f2
26 changed files with 1058 additions and 30 deletions
|
|
@ -1,73 +0,0 @@
|
|||
using System.Text.Json;
|
||||
|
||||
namespace VideoDownloader.Mobile;
|
||||
|
||||
public sealed record OfflineItem(string Id, string FileName, long SizeBytes);
|
||||
|
||||
/// <summary>
|
||||
/// 폰 오프라인 저장(U4): 라이브러리 항목을 앱 전용 폴더에 저장·목록·삭제.
|
||||
/// manifest.json(id→파일명)으로 서버 항목과 매핑한다.
|
||||
/// </summary>
|
||||
public sealed class OfflineStore
|
||||
{
|
||||
public static OfflineStore Default { get; } = new();
|
||||
|
||||
private readonly string _dir;
|
||||
private readonly string _manifestPath;
|
||||
private readonly object _gate = new();
|
||||
private Dictionary<string, string> _manifest;
|
||||
|
||||
public OfflineStore()
|
||||
{
|
||||
_dir = Path.Combine(FileSystem.AppDataDirectory, "offline");
|
||||
_manifestPath = Path.Combine(_dir, "manifest.json");
|
||||
try
|
||||
{
|
||||
if (File.Exists(_manifestPath))
|
||||
_manifest = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(_manifestPath)) ?? new();
|
||||
}
|
||||
catch { }
|
||||
_manifest ??= new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public string Directory => _dir;
|
||||
|
||||
public string PathFor(string id) => Path.Combine(_dir, id + Path.GetExtension(_manifest.GetValueOrDefault(id, ".mp4")));
|
||||
|
||||
public bool Exists(string id) { lock (_gate) { var p = PathFor(id); return File.Exists(p) && _manifest.ContainsKey(id); } }
|
||||
|
||||
/// <summary>다운로드 완료 후 등록.</summary>
|
||||
public void Record(string id, string fileName)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(_dir);
|
||||
_manifest[id] = fileName;
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(string id)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
try { if (File.Exists(PathFor(id))) File.Delete(PathFor(id)); } catch { }
|
||||
_manifest.Remove(id);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public List<OfflineItem> List()
|
||||
{
|
||||
lock (_gate)
|
||||
return _manifest.Select(kv =>
|
||||
{
|
||||
var p = PathFor(kv.Key);
|
||||
return new OfflineItem(kv.Key, kv.Value, File.Exists(p) ? new FileInfo(p).Length : 0);
|
||||
}).Where(i => i.SizeBytes > 0).ToList();
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
try { System.IO.Directory.CreateDirectory(_dir); File.WriteAllText(_manifestPath, JsonSerializer.Serialize(_manifest)); } catch { }
|
||||
}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue