Skip to content

Commit

Permalink
allow empty file response
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekwav committed Dec 7, 2024
1 parent cf35584 commit 586aff9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Services/PreviewService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task<Preview> 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<string>() { "1mfgd8A3YEGnfidqz4q0xg==" };
var brokenFilehash = new HashSet<string>() { "1mfgd8A3YEGnfidqz4q0xg==", null };

if (hash == "��D`��9��U�\u0006�/�o" && !uri.Authority.Contains("coflnet"))
{
Expand All @@ -76,12 +76,11 @@ public async Task<Preview> 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<Items.Client.Api.IItemsApi>().ItemItemTagGetWithHttpInfoAsync(tag, true);
Console.WriteLine($"info {info.StatusCode}");
Expand All @@ -101,7 +100,7 @@ public async Task<Preview> 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);
}
Expand Down

0 comments on commit 586aff9

Please sign in to comment.