lucy-dirsum

0.1.1 • Public • Published

Lucy dirsum Build Status

Create an md5 digest of all content inside a directory.

Part of Lucidity project.

Installation

npm install lucy-dirsum --save

dirsum ( path, callback, ignoreFunction )

Returns an (async) md5 digest of all content inside a directory. The ignore function can be used to ignore files. It receives a local path to directory and filename. For example, scanning '/some/directory', the file '/some/directory/foo/bar.txt' is checked by calling the ignore function with ( 'foo/bar.txt', 'bar.txt' ). Returning true ignores the file. Default ignore function is to ignore files starting with a dot ('.').

The hashing algorithm includes file names (and thus detects empty directory and file move) and does not read large files in memory (it uses read streams). Speed is directly proportional to fs.createReadStream (36s for 12G of data on i7 cpu).

Usage example

const dirsum = require ( 'lucy-dirsum' )
 
dirsum
( '/some/directory'
, function ( err, digest )
  { if ( err )
    { // ...
    }
    else
    { console.log ( `Hex digest for '/some/directory' is '${ digest }'.` )
    }
  }
, function ( path, filename )
  { return /^\./.exec ( filename )
        || /^info\.txt/.exec ( path ) // ignore info.txt at root
  }
)

Tests

 npm test

Contributing

Please use 'jessy style'.

Add unit tests for any new or changed functionality.

Release History

  • 0.1.1 (2015-09-22) Fixed npm readme.
  • 0.1.0 (2015-09-22) Initial release.

Package Sidebar

Install

npm i lucy-dirsum

Weekly Downloads

4

Version

0.1.1

License

MIT

Last publish

Collaborators

  • gbucher