Fixed bugs causing "Hash ... does not match file digest ..." errors

This commit is contained in:
CalDescent 2022-04-30 11:26:05 +01:00
parent dd55dc277b
commit e5b4b61832

View File

@ -93,10 +93,12 @@ public class ArbitraryDataFile {
File outputFile = outputFilePath.toFile(); File outputFile = outputFilePath.toFile();
try (FileOutputStream outputStream = new FileOutputStream(outputFile)) { try (FileOutputStream outputStream = new FileOutputStream(outputFile)) {
outputStream.write(fileContent); outputStream.write(fileContent);
outputStream.close();
this.filePath = outputFilePath; this.filePath = outputFilePath;
// Verify hash // Verify hash
if (!this.hash58.equals(this.digest58())) { String digest58 = this.digest58();
LOGGER.error("Hash {} does not match file digest {} for signature: {}", this.hash58, this.digest58(), Base58.encode(signature)); if (!this.hash58.equals(digest58)) {
LOGGER.error("Hash {} does not match file digest {} for signature: {}", this.hash58, digest58, Base58.encode(signature));
this.delete(); this.delete();
throw new DataException("Data file digest validation failed"); throw new DataException("Data file digest validation failed");
} }