Skip to content

Commit c818c88

Browse files
Created a "write()" method in Package that accepts a Consumer-function for usecase-specific manipulation of the package contents.
1 parent d44156b commit c818c88

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/test/java/io/frictionlessdata/datapackage/PackageTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,8 @@ public void testWriteWithConsumer() throws Exception{
668668
File fingerprints = new File (dir, "fingerprints.txt");
669669
String content = String.join("\n", Files.readAllLines(fingerprints.toPath()));
670670
String refContent =
671-
"datapackage.json\t653e78055470efedea58350d50f6aa603a20f81835770f4d50445f7b1262ca77\n" +
672-
"schema.json\t44ffaa100fdfa343f3b517c67b8ccbceffab9cf94764b0214fdbe46dd992fce6";
671+
"datapackage.json\te3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n" +
672+
"schema.json\te3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
673673
Assertions.assertEquals(refContent, content);
674674
}
675675

@@ -888,12 +888,15 @@ private static void fingerprintFiles(Path path) {
888888

889889
for (File f : path.toFile().listFiles()) {
890890
if (f.isFile()) {
891-
try (DigestInputStream dis = new DigestInputStream(Files.newInputStream(f.toPath()), md)) {
891+
/*try (DigestInputStream dis = new DigestInputStream(Files.newInputStream(f.toPath()), md)) {
892892
while (true) {
893893
if (dis.read() == -1) break;
894894
}
895895
md = dis.getMessageDigest();
896-
}
896+
}*/
897+
String content = String.join("\n", Files.readAllLines(f.toPath()));
898+
content = content.replaceAll("[\\n\\r]+", "\n");
899+
md.digest(content.getBytes());
897900

898901
StringBuilder result = new StringBuilder();
899902
for (byte b : md.digest()) {

0 commit comments

Comments
 (0)