Skip to content

Commit bdd05f5

Browse files
committed
client v0.0.2.1 - fixed incorrect handling of READ response for cache miss when query was cancelled on the client side
1 parent 5172571 commit bdd05f5

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

client/ContentHash.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace Hash;
22

33
using System.Buffers;
44
using System.Buffers.Binary;
5+
using System.Runtime.InteropServices;
56
using System.Security.Cryptography;
67

78
public readonly struct ContentHash(long a, long b, long c, long d): IEquatable<ContentHash> {
@@ -64,6 +65,11 @@ public static ContentHash Compute(SHA256 sha256, ReadOnlySpan<byte> buffer) {
6465
#endif
6566
return FromBytes(hash);
6667
}
68+
69+
public int Lo4() {
70+
var bytes = MemoryMarshal.AsBytes([this]);
71+
return BinaryPrimitives.ReadInt32LittleEndian(bytes);
72+
}
6773

6874
#if NET6_0_OR_GREATER
6975
public static ContentHash Compute(ReadOnlySpan<byte> buffer) {

client/ContentStreamClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ await this.stream.ReadExact(buffer, tmp: this.receiveBuffer, cancel)
118118

119119
query.Completion.TrySetResult(read);
120120
} else {
121-
await this.stream.Drain(count: read, this.receiveBuffer, cancel)
122-
.ConfigureAwait(false);
121+
if (read != -1)
122+
await this.stream.Drain(count: read, this.receiveBuffer, cancel)
123+
.ConfigureAwait(false);
123124
}
124125

125126
break;

client/Hash.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<!-- Package stuff -->
1414
<PackageId>Borg.Hash.Client</PackageId>
15-
<Version>0.0.2</Version>
15+
<Version>0.0.2.1</Version>
1616
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1717
<PackageLicenseFile Condition="$(PackageLicenseExpression) == ''">LICENSE</PackageLicenseFile>
1818
<PackageReadmeFile>README.md</PackageReadmeFile>

0 commit comments

Comments
 (0)