* Initial implementation of announce with diff

* Add missing logic pieces

* Change in logic

* Fix checksums

* Add deduplication logic

* Update SetPart.cs

* Use standalone endpoint for diff

* Use different hashcode impl

* Update AssetForListing.cs

* Misc

* Push all the changes for this to finally work

* Use original index rather than self-calculated

ASFB makes some calculations based on index, it's better for us to have holes rather than hiding skipped items.

* Handle edge case of no assets after deduplication

* Remove dead code

* Address trim warnings

* Misc optimization
This commit is contained in:
Łukasz Domeradzki
2023-11-29 00:08:16 +01:00
committed by GitHub
parent 8cf2d1bc94
commit 36ae066c65
17 changed files with 771 additions and 156 deletions

View File

@@ -30,7 +30,6 @@ using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using ArchiSteamFarm.Helpers;
@@ -323,7 +322,7 @@ public static class ASF {
byte[] responseBytes = response.Content as byte[] ?? response.Content.ToArray();
string checksum = Convert.ToHexString(SHA512.HashData(responseBytes));
string checksum = Utilities.GenerateChecksumFor(responseBytes);
if (!checksum.Equals(remoteChecksum, StringComparison.OrdinalIgnoreCase)) {
ArchiLogger.LogGenericError(Strings.ChecksumWrong);

View File

@@ -29,6 +29,7 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Resources;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using AngleSharp.Dom;
@@ -51,6 +52,15 @@ public static class Utilities {
private static readonly JwtSecurityTokenHandler JwtSecurityTokenHandler = new();
[PublicAPI]
public static string GenerateChecksumFor(byte[] source) {
ArgumentNullException.ThrowIfNull(source);
byte[] hash = SHA512.HashData(source);
return Convert.ToHexString(hash);
}
[PublicAPI]
public static string GetArgsAsText(string[] args, byte argsToSkip, string delimiter) {
ArgumentNullException.ThrowIfNull(args);
@@ -321,7 +331,7 @@ public static class Utilities {
}
}
return (result.Score < 4, suggestions is { Count: > 0 } ? string.Join(" ", suggestions.Where(static suggestion => suggestion.Length > 0)) : null);
return (result.Score < 4, suggestions is { Count: > 0 } ? string.Join(' ', suggestions.Where(static suggestion => suggestion.Length > 0)) : null);
}
internal static void WarnAboutIncompleteTranslation(ResourceManager resourceManager) {