aboutsummaryrefslogtreecommitdiff
path: root/jgvariant-ostree/src/main/java
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-29 21:53:50 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2021-12-29 21:53:50 +0100
commitf96d0e31503a64e7648c7f78f9b9db6ae4ad9cf7 (patch)
tree5fc40e065833d5c23ee845b2df85e09f84129ac9 /jgvariant-ostree/src/main/java
parent05114647f0cd37fd09d344a088d5c57c4ac68a32 (diff)
Checksum: Convert 0-sized checksums to all-zeros checksums.
Change-Id: Ia2429edafcdc93aad01310f66f489c3dd54ec365
Diffstat (limited to 'jgvariant-ostree/src/main/java')
-rw-r--r--jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java
index 705e27c..ce5f9b0 100644
--- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java
+++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Checksum.java
@@ -16,6 +16,10 @@ public record Checksum(ByteString byteString) {
private static final Decoder<Checksum> DECODER = ByteString.decoder().map(Checksum::new);
public Checksum {
+ if (byteString.size() == 0) {
+ byteString = zero().byteString;
+ }
+
if (byteString.size() != SIZE) {
throw new IllegalArgumentException(
"attempted to construct Checksum of length %d (expected: %d)"