1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:37:34 +00:00

checksum: Don't read the entire input file in memory

Unsurprisingly, this doesn't work too well if the input file is in the
gigabyte range.
This commit is contained in:
Jean-Baptiste Boric 2021-03-18 22:58:39 +01:00 committed by Andreas Kling
parent eea5a5ed5d
commit 67f01fd82e

View file

@ -85,7 +85,9 @@ int main(int argc, char** argv)
has_error = true;
continue;
}
hash.update(file->read_all());
while (!file->eof() && !file->has_error())
hash.update(file->read(PAGE_SIZE));
auto digest = hash.digest();
auto digest_data = digest.immutable_data();
StringBuilder builder;