MCPcopy Create free account
hub / github.com/6174/comflowyspace / calculateFileHash

Function calculateFileHash

apps/node/src/modules/utils/file-hash.ts:8–17  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

6 * @returns A promise that resolves to the hash string of the file.
7 */
8export async function calculateFileHash(filePath: string): Promise<string> {
9 return new Promise((resolve, reject) => {
10 const hash = createHash('sha256'); // or 'md5', 'sha1', etc.
11 const stream = createReadStream(filePath);
12
13 stream.on('error', err => reject(err));
14 stream.on('data', chunk => hash.update(chunk));
15 stream.on('end', () => resolve(hash.digest('hex')));
16 });
17}

Callers

nothing calls this directly

Calls 1

onMethod · 0.45

Tested by

no test coverage detected