fix: 修复因重定向导致 ETag 缓存与原始地址不符的问题

This commit is contained in:
uye
2025-07-04 19:18:52 +08:00
parent 0c78e0f5fa
commit 68c8ff73f8
3 changed files with 4 additions and 4 deletions

View File

@@ -73,10 +73,10 @@ namespace MaaWpfGui.Helper
Save();
}
public static void Set(HttpResponseMessage? response)
// UPDATE: 重定向会导致 uri 变成其他地址,导致存的 ETag 无法匹配原始地址,所以要传入原始地址
public static void Set(HttpResponseMessage? response, string uri)
{
var etag = response?.Headers.ETag?.Tag;
var uri = response?.RequestMessage?.RequestUri?.ToString();
if (string.IsNullOrEmpty(uri) || string.IsNullOrEmpty(etag))
{
return;

View File

@@ -57,7 +57,7 @@ namespace MaaWpfGui.Services.Web
await File.WriteAllTextAsync(cache, body);
ETagCache.Set(response);
ETagCache.Set(response, url);
return json;
}

View File

@@ -257,7 +257,7 @@ namespace MaaWpfGui.ViewModels.UI
DoNotRemindThisAnnouncementAgain = false;
}
ETagCache.Set(response);
ETagCache.Set(response, url);
ETagCache.Save();
}