Skip to content

Commit

Permalink
Use BufferedInputStream and provide simple Bash command
Browse files Browse the repository at this point in the history
  • Loading branch information
tkuhn committed Jun 29, 2017
1 parent 9305d90 commit 5523e83
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions scripts/get-FA-code
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sha256sum $1 | awk '{print $1}' | xxd -r -p | base64 | sed 's/+/-/g' | sed 's|/|_|g' | sed 's/=$//' | sed 's/^/FA/'
3 changes: 2 additions & 1 deletion src/main/java/net/trustyuri/file/FileModule.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.trustyuri.file;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;

Expand Down Expand Up @@ -28,7 +29,7 @@ public int getDataPartLength() {
@Override
public boolean hasCorrectHash(TrustyUriResource r) throws IOException {
FileHasher hasher = new FileHasher();
String ac = hasher.makeArtifactCode(r.getInputStream());
String ac = hasher.makeArtifactCode(new BufferedInputStream(r.getInputStream()));
return r.getArtifactCode().equals(ac);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/trustyuri/file/ProcessFile.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.trustyuri.file;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand All @@ -15,7 +16,7 @@ public static void main(String[] args) throws IOException {
public static void process(File file) throws IOException {
String filename = file.getName();
FileHasher hasher = new FileHasher();
String ac = hasher.makeArtifactCode(new FileInputStream(file));
String ac = hasher.makeArtifactCode(new BufferedInputStream(new FileInputStream(file)));
String ext = "";
String base = filename;
if (filename.matches(".+\\.[A-Za-z0-9\\-_]{0,20}")) {
Expand Down

0 comments on commit 5523e83

Please sign in to comment.