src/providers/subdb.js
async function hash (file) {
  const filesize = await fileUtil.getFileSize(file)

  const chunkSize = 64 * 1024

  const firstBytesPromise = fileUtil.readBytes({
    file,
    chunkSize,
    start: 0
  })

  const lastBytesPromise = fileUtil.readBytes({
    file,
    chunkSize,
    start: filesize - chunkSize
  })

  const [ firstBytes, lastBytes ] = await Promise.all([firstBytesPromise, lastBytesPromise])

  return crypto
    .createHash('md5')
    .update(firstBytes)
    .update(lastBytes)
    .digest('hex')
}
async function hash (file) {
  const filesize = await fileUtil.getFileSize(file)

  const chunkSize = 64 * 1024

  const firstBytesPromise = fileUtil.readBytes({
    file,
    chunkSize,
    start: 0
  })

  const lastBytesPromise = fileUtil.readBytes({
    file,
    chunkSize,
    start: filesize - chunkSize
  })

  const [ firstBytes, lastBytes ] = await Promise.all([firstBytesPromise, lastBytesPromise])

  return crypto
    .createHash('md5')
    .update(firstBytes)
    .update(lastBytes)
    .digest('hex')
}
async function hash ( file ) { const filesize = await fileUtil . getFileSize ( file ) const chunkSize = 64 * 1024 const firstBytesPromise = fileUtil . readBytes ( { file , chunkSize , start : 0 } ) const lastBytesPromise = fileUtil . readBytes ( { file , chunkSize , start : filesize - chunkSize } ) const [ firstBytes , lastBytes ] = await Promise . all ( [ firstBytesPromise , lastBytesPromise ] ) return crypto . createHash ( 'md5' ) . update ( firstBytes ) . update ( lastBytes ) . digest ( 'hex' ) }
Create the hash used to identify a file.

@param {string} file - path to a file
@returns {Promise<string>} a hex string representing the MD5 digest of the
first 64kB and the last 64kB of the given file
Create the hash used to identify a file .