MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / md5FileSync

Function md5FileSync

scripts/md5sum.js:27–45  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

25
26// Synchronously calculate MD5 hash of a file using streaming to handle large files efficiently
27function md5FileSync (filename) {
28 const BUFFER_SIZE = 8192;
29 const fd = fs.openSync(filename, 'r');
30 const hash = crypto.createHash('md5');
31 const buffer = Buffer.alloc(BUFFER_SIZE);
32
33 try {
34 let bytesRead;
35
36 do {
37 bytesRead = fs.readSync(fd, buffer, 0, BUFFER_SIZE);
38 hash.update(buffer.slice(0, bytesRead));
39 } while (bytesRead === BUFFER_SIZE);
40 } finally {
41 fs.closeSync(fd);
42 }
43
44 return hash.digest('hex');
45}
46
47// Generate MD5 checksums for multiple files and output in standard format
48function generate(files) {

Callers 2

generateFunction · 0.85
validateFunction · 0.85

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected