Skip to content

Commit 0067ffd

Browse files
committed
Add InvalidateCache method
1 parent 833f225 commit 0067ffd

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

TACTSharp/CDN.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private void LoadCDNs()
103103
if (Settings.LogLevel <= TSLogLevel.Info)
104104
Console.WriteLine("Ping to " + server + ": " + ping + "ms");
105105

106-
if(server == "blzddist1-a.akamaihd.net")
106+
if (server == "blzddist1-a.akamaihd.net")
107107
ping += 5000; // TEMP: Penalize Akamai for having missing files as of November 2025
108108
return (server, ping);
109109
}
@@ -589,7 +589,7 @@ public unsafe bool TryGetLocalFile(string eKey, out ReadOnlySpan<byte> data)
589589
{
590590
var url = $"https://{CDNServers[i]}/tpr/configs/data/{hash[0]}{hash[1]}/{hash[2]}{hash[3]}/{hash}";
591591

592-
if(Settings.LogLevel <= TSLogLevel.Info)
592+
if (Settings.LogLevel <= TSLogLevel.Info)
593593
Console.WriteLine("Downloading " + url);
594594

595595
var request = new HttpRequestMessage(HttpMethod.Get, url);
@@ -598,7 +598,7 @@ public unsafe bool TryGetLocalFile(string eKey, out ReadOnlySpan<byte> data)
598598

599599
if (!response.IsSuccessStatusCode)
600600
{
601-
if(Settings.LogLevel <= TSLogLevel.Warn)
601+
if (Settings.LogLevel <= TSLogLevel.Warn)
602602
Console.WriteLine("Encountered HTTP " + response.StatusCode + " downloading " + hash + " from " + CDNServers[i]);
603603

604604
continue;
@@ -615,7 +615,7 @@ public unsafe bool TryGetLocalFile(string eKey, out ReadOnlySpan<byte> data)
615615
}
616616
catch (Exception e)
617617
{
618-
if(Settings.LogLevel <= TSLogLevel.Warn)
618+
if (Settings.LogLevel <= TSLogLevel.Warn)
619619
Console.WriteLine("Failed to download file: " + e.Message);
620620

621621
File.Delete(cachePath);
@@ -628,5 +628,12 @@ public unsafe bool TryGetLocalFile(string eKey, out ReadOnlySpan<byte> data)
628628

629629
throw new FileNotFoundException("Exhausted all CDNs trying to download " + hash);
630630
}
631+
632+
public void InvalidateCache(string type, string hash)
633+
{
634+
var cachePath = Path.Combine(Settings.CacheDir, ProductDirectory, type, hash);
635+
if (File.Exists(cachePath))
636+
File.Delete(cachePath);
637+
}
631638
}
632639
}

0 commit comments

Comments
 (0)