import type { Stats } from 'fs' ; import { generateFileHash , getFileCacheKey } from './utils' ; import { IFileHashCache } from './file_hash_cache' ; /**
 *  Get the hash of a file via a file descriptor
 */ export async function getFileHash ( cache , path , stat , fd ) { const key = getFileCacheKey ( path , stat ) ; const cached = cache . get ( key ) ; if ( cached ) { return await cached ; } const promise = generateFileHash ( fd ) . catch ( ( error ) => { cache . del ( key ) ; throw error ; } ) ; cache . set ( key , promise ) ; return await promise ; }