forked from Qortal/qortal
Use a buffered digest where possible instead of reading the whole file contents into memory.
This commit is contained in:
parent
60f96d15bd
commit
bada4fd140
@ -350,7 +350,7 @@ public class ArbitraryDataDiff {
|
||||
|
||||
private static byte[] digestFromPath(Path path) {
|
||||
try {
|
||||
return Crypto.digest(Files.readAllBytes(path));
|
||||
return Crypto.digest(path.toFile());
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -111,8 +111,7 @@ public class ArbitraryDataFile {
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
try {
|
||||
byte[] fileContent = Files.readAllBytes(file.toPath());
|
||||
byte[] digest = Crypto.digest(fileContent);
|
||||
byte[] digest = Crypto.digest(file);
|
||||
ArbitraryDataFile arbitraryDataFile = ArbitraryDataFile.fromHash(digest);
|
||||
|
||||
// Copy file to data directory if needed
|
||||
@ -502,8 +501,7 @@ public class ArbitraryDataFile {
|
||||
File file = this.getFile();
|
||||
if (file != null && file.exists()) {
|
||||
try {
|
||||
byte[] fileContent = Files.readAllBytes(file.toPath());
|
||||
return Crypto.digest(fileContent);
|
||||
return Crypto.digest(file);
|
||||
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Couldn't compute digest for ArbitraryDataFile");
|
||||
|
Loading…
x
Reference in New Issue
Block a user