From 586aff9462f4dbe9ebdba31c4fd7b56448672bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84kwav?= Date: Sat, 7 Dec 2024 17:06:12 +0100 Subject: [PATCH] allow empty file response --- Services/PreviewService.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Services/PreviewService.cs b/Services/PreviewService.cs index efe2077..345f182 100644 --- a/Services/PreviewService.cs +++ b/Services/PreviewService.cs @@ -66,7 +66,7 @@ public async Task GetItemPreview(string tag, int size = 32) var uri = skyCryptClient.BuildUri(request); var response = await GetProxied(uri, size); var hash = Encoding.UTF8.GetString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(tag))); - var brokenFilehash = new HashSet() { "1mfgd8A3YEGnfidqz4q0xg==" }; + var brokenFilehash = new HashSet() { "1mfgd8A3YEGnfidqz4q0xg==", null }; if (hash == "��D`��9��U�\u0006�/�o" && !uri.Authority.Contains("coflnet")) { @@ -76,12 +76,11 @@ public async Task GetItemPreview(string tag, int size = 32) response = await GetProxied(uri, size); Console.WriteLine($"retrying with coflnet {uri} {response.StatusCode}"); } - var fileHashBase64 = Convert.ToBase64String(MD5.Create().ComputeHash(response.RawBytes)); + var fileHashBase64 = response?.RawBytes == null ? null : Convert.ToBase64String(MD5.Create().ComputeHash(response.RawBytes)); Items.Client.Model.Item details = null; if (response.StatusCode != System.Net.HttpStatusCode.OK || brokenFilehash.Contains(fileHashBase64)) { - var isPet = tag.StartsWith("PET_"); - if (!isPet) + if (!NBT.IsPet(tag)) dev.Logger.Instance.Error($"Failed to load item preview for {tag} from {uri} code {response.StatusCode}"); var info = await DiHandler.GetService().ItemItemTagGetWithHttpInfoAsync(tag, true); Console.WriteLine($"info {info.StatusCode}"); @@ -101,7 +100,7 @@ public async Task GetItemPreview(string tag, int size = 32) Console.WriteLine($"retrieving from api"); url = await GetIconUrl(tag); }; - if(url.StartsWith("https://texture")) + if (url.StartsWith("https://texture")) { url = ConvertTextureUrlToSkull(config["SKYCRYPT_BASE_URL"], url); }