index.js
function _check(mnode, cb){
    if (mnode.node.filePath) {
      fs.stat(path.resolve(root, mnode.node.filePath), function(err, stats){
        if (err) return cb(err);
        mnode.node.dateModified = stats.mtime.toISOString();
        if (psize) { mnode.node[psize] = stats.size; }
        cb(null);
      });
    } else if (mnode.node.hasPart) {
      var hasPart = (Array.isArray(mnode.node.hasPart)) ? mnode.node.hasPart : [mnode.node.hasPart];
      async.each(hasPart, function(part, cb2){
        if (part.filePath) {
          fs.stat(path.resolve(root, part.filePath), function(err, stats){
            if (err) return cb2(err);
            part.dateModified = stats.mtime.toISOString();

            var type = packager.getType(part, packager.getRanges('hasPart'));
            var isSoftwareApplication = type && packager.isClassOrSubClassOf(type, 'SoftwareApplication');
            var isMediaObject = type && packager.isClassOrSubClassOf(type, 'MediaObject');

            if (isSoftwareApplication) {
              part.fileSize = stats.size;
            } else if (isMediaObject) {
              part.contentSize = stats.size;
            }

            cb2(null);
          });
        } else {
          cb2(null);
        }
      }, cb);
    } else {
      cb(null);
    }
  }
function _check(mnode, cb){
    if (mnode.node.filePath) {
      fs.stat(path.resolve(root, mnode.node.filePath), function(err, stats){
        if (err) return cb(err);
        mnode.node.dateModified = stats.mtime.toISOString();
        if (psize) { mnode.node[psize] = stats.size; }
        cb(null);
      });
    } else if (mnode.node.hasPart) {
      var hasPart = (Array.isArray(mnode.node.hasPart)) ? mnode.node.hasPart : [mnode.node.hasPart];
      async.each(hasPart, function(part, cb2){
        if (part.filePath) {
          fs.stat(path.resolve(root, part.filePath), function(err, stats){
            if (err) return cb2(err);
            part.dateModified = stats.mtime.toISOString();

            var type = packager.getType(part, packager.getRanges('hasPart'));
            var isSoftwareApplication = type && packager.isClassOrSubClassOf(type, 'SoftwareApplication');
            var isMediaObject = type && packager.isClassOrSubClassOf(type, 'MediaObject');

            if (isSoftwareApplication) {
              part.fileSize = stats.size;
            } else if (isMediaObject) {
              part.contentSize = stats.size;
            }

            cb2(null);
          });
        } else {
          cb2(null);
        }
      }, cb);
    } else {
      cb(null);
    }
  }
function _check ( mnode , cb ) { if ( mnode . node . filePath ) { fs . stat ( path . resolve ( root , mnode . node . filePath ) , function ( err , stats ) { if ( err ) return cb ( err ) ; mnode . node . dateModified = stats . mtime . toISOString ( ) ; if ( psize ) { mnode . node [ psize ] = stats . size ; } cb ( null ) ; } ) ; } else if ( mnode . node . hasPart ) { var hasPart = ( Array . isArray ( mnode . node . hasPart ) ) ? mnode . node . hasPart : [ mnode . node . hasPart ] ; async . each ( hasPart , function ( part , cb2 ) { if ( part . filePath ) { fs . stat ( path . resolve ( root , part . filePath ) , function ( err , stats ) { if ( err ) return cb2 ( err ) ; part . dateModified = stats . mtime . toISOString ( ) ; var type = packager . getType ( part , packager . getRanges ( 'hasPart' ) ) ; var isSoftwareApplication = type && packager . isClassOrSubClassOf ( type , 'SoftwareApplication' ) ; var isMediaObject = type && packager . isClassOrSubClassOf ( type , 'MediaObject' ) ; if ( isSoftwareApplication ) { part . fileSize = stats . size ; } else if ( isMediaObject ) { part . contentSize = stats . size ; } cb2 ( null ) ; } ) ; } else { cb2 ( null ) ; } } , cb ) ; } else { cb ( null ) ; } }
check that all the files are here and update dateModified and contentSize
check that all the files are here and update dateModified and contentSize