diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2023-01-11 11:23:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-11 11:23:39 +0100 |
commit | b9fb186273c01db3e731a7be99544391d58e78a9 (patch) | |
tree | d179f1061d8c9f25c2040232cd8c5a46d05ae39d /controller-server | |
parent | 1a7e6af169ffb74e0acfef27500935038921bc80 (diff) | |
parent | 081d6ae50abeac0b859d53324f1950ae38bcd97e (diff) |
Merge pull request #25497 from vespa-engine/jonmv/include-file-names-in-content-hash
Include file names in content hash
Diffstat (limited to 'controller-server')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java index 0afca9d830f..4a8bc3cd09a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackage.java @@ -28,8 +28,10 @@ import com.yahoo.vespa.hosted.controller.deployment.ZipBuilder; import com.yahoo.yolean.Exceptions; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.Paths; @@ -220,11 +222,16 @@ public class ApplicationPackage { // Hashes all files and settings that require a deployment to be forwarded to configservers private String calculateBundleHash(byte[] zippedContent) { Predicate<String> entryMatcher = name -> ! name.endsWith(deploymentFile) && ! name.endsWith(buildMetaFile); - SortedMap<String, Long> crcByEntry = new TreeMap<>(); Options options = Options.standard().pathPredicate(entryMatcher); HashingOutputStream hashOut = new HashingOutputStream(Hashing.murmur3_128(-1), OutputStream.nullOutputStream()); + ArchiveFile file; try (ArchiveStreamReader reader = ArchiveStreamReader.ofZip(new ByteArrayInputStream(zippedContent), options)) { - while (reader.readNextTo(hashOut) != null); + while ((file = reader.readNextTo(hashOut)) != null) { + hashOut.write(file.path().toString().getBytes(UTF_8)); + } + } + catch (IOException e) { + throw new UncheckedIOException(e); } return hasher().putLong(hashOut.hash().asLong()) .putInt(deploymentSpec.deployableHashCode()) |