Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ public static PackageAttributes forFileToStage(
.toString();
destination.setLocation(resourcePath);
destination.setName(dest);
destination.setSha256(hash);
return new AutoValue_PackageUtil_PackageAttributes(
file, null, destination, file.length(), hash);
}
Expand All @@ -456,6 +457,7 @@ public static PackageAttributes forBytesToStage(
DataflowPackage targetPackage = new DataflowPackage();
targetPackage.setName(target);
targetPackage.setLocation(resourcePath);
targetPackage.setSha256(hashCode.toString());

return new AutoValue_PackageUtil_PackageAttributes(
null, bytes, targetPackage, size, hashCode.toString());
Expand All @@ -465,6 +467,7 @@ public PackageAttributes withPackageName(String overridePackageName) {
DataflowPackage newDestination = new DataflowPackage();
newDestination.setName(overridePackageName);
newDestination.setLocation(getDestination().getLocation());
newDestination.setSha256(getHash());

return new AutoValue_PackageUtil_PackageAttributes(
getSource(), getBytes(), newDestination, getSize(), getHash());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ public void testFileWithExtensionPackageNamingAndSize() throws Exception {
assertThat(target.getName(), endsWith(".txt"));
assertThat(target.getLocation(), equalTo(STAGING_PATH + target.getName()));
assertThat(attr.getSize(), equalTo((long) contents.length()));
String expectedHash = Files.asByteSource(tmpFile).hash(Hashing.sha256()).toString();
assertThat(target.getSha256(), equalTo(expectedHash));
}

@Test
Expand Down Expand Up @@ -299,6 +301,8 @@ public void testPackageUploadWithFileSucceeds() throws Exception {

assertThat(target.getName(), endsWith(".txt"));
assertThat(target.getLocation(), equalTo(STAGING_PATH + target.getName()));
String expectedHash = Files.asByteSource(tmpFile).hash(Hashing.sha256()).toString();
assertThat(target.getSha256(), equalTo(expectedHash));
assertThat(
new LineReader(Channels.newReader(pipe.source(), StandardCharsets.UTF_8.name())).readLine(),
equalTo(contents));
Expand Down
Loading