lib/delta/local-delta.js
function(dirPath, oldDirPath, parentNodeId, callback) {
    fsWrap.readdir(dirPath, (err, nodes) => {
      //if it is not possible to read dir abort sync
      if(err) {
        logger.warning('Error while reading dir', {category: 'sync-local-delta', dirPath, err});
        throw new BlnDeltaError(err.message);
      }

      async.eachSeries(nodes, (node, cb) => {
        var nodePath = utility.joinPath(dirPath, node);

        try {
          var stat = fsWrap.lstatSync(nodePath);
        } catch(e) {
          logger.warning('findChanges got lstat error on node', {category: 'sync-local-delta', nodePath, code: e.code});
          throw new BlnDeltaError(e.message);
        }

        if(utility.isExcludeFile(node)) {
          logger.info('LOCAL DELTA: ignoring file \'' + nodePath + '\' matching exclude pattern');
          return cb(null);
        }

        if(utility.hasInvalidChars(node)) {
          logger.info('LOCAL DELTA: ignoring file \'' + name + '\' because filename contains invalid chars');
          return cb(undefined);
        }

        if(stat.isSymbolicLink()) {
          logger.info('LOCAL DELTA: ignoring symlink \'' + nodePath + '\'');
          return cb(null);
        }

        syncDb.findByIno(stat.ino, (err, syncedNode) => {
          if(stat.isDirectory()) {
            let query = {path: nodePath};

            if(syncedNode && syncedNode.remoteId) {
              query.remoteId = syncedNode.remoteId;
            }

            ignoreDb.isIgnoredNode(query, (err, isIgnored) => {
              if(err) return cb(err);

              if(isIgnored) {
                logger.info('ignoring directory \'' + nodePath + '\' because it is ignored by ignoredNodes', {category: 'sync-local-delta'});

                return cb(null);
              }

              this.analyzeNodeForChanges(node, dirPath, oldDirPath, parentNodeId, stat, syncedNode, cb);
            });
          } else {
            this.analyzeNodeForChanges(node, dirPath, oldDirPath, parentNodeId, stat, syncedNode, cb);
          }
        });
      }, callback);
    });
  }
function(dirPath, oldDirPath, parentNodeId, callback) {
    fsWrap.readdir(dirPath, (err, nodes) => {
      //if it is not possible to read dir abort sync
      if(err) {
        logger.warning('Error while reading dir', {category: 'sync-local-delta', dirPath, err});
        throw new BlnDeltaError(err.message);
      }

      async.eachSeries(nodes, (node, cb) => {
        var nodePath = utility.joinPath(dirPath, node);

        try {
          var stat = fsWrap.lstatSync(nodePath);
        } catch(e) {
          logger.warning('findChanges got lstat error on node', {category: 'sync-local-delta', nodePath, code: e.code});
          throw new BlnDeltaError(e.message);
        }

        if(utility.isExcludeFile(node)) {
          logger.info('LOCAL DELTA: ignoring file \'' + nodePath + '\' matching exclude pattern');
          return cb(null);
        }

        if(utility.hasInvalidChars(node)) {
          logger.info('LOCAL DELTA: ignoring file \'' + name + '\' because filename contains invalid chars');
          return cb(undefined);
        }

        if(stat.isSymbolicLink()) {
          logger.info('LOCAL DELTA: ignoring symlink \'' + nodePath + '\'');
          return cb(null);
        }

        syncDb.findByIno(stat.ino, (err, syncedNode) => {
          if(stat.isDirectory()) {
            let query = {path: nodePath};

            if(syncedNode && syncedNode.remoteId) {
              query.remoteId = syncedNode.remoteId;
            }

            ignoreDb.isIgnoredNode(query, (err, isIgnored) => {
              if(err) return cb(err);

              if(isIgnored) {
                logger.info('ignoring directory \'' + nodePath + '\' because it is ignored by ignoredNodes', {category: 'sync-local-delta'});

                return cb(null);
              }

              this.analyzeNodeForChanges(node, dirPath, oldDirPath, parentNodeId, stat, syncedNode, cb);
            });
          } else {
            this.analyzeNodeForChanges(node, dirPath, oldDirPath, parentNodeId, stat, syncedNode, cb);
          }
        });
      }, callback);
    });
  }
function ( dirPath , oldDirPath , parentNodeId , callback ) { fsWrap . readdir ( dirPath , ( err , nodes ) => { //if it is not possible to read dir abort sync if ( err ) { logger . warning ( 'Error while reading dir' , { category : 'sync-local-delta' , dirPath , err } ) ; throw new BlnDeltaError ( err . message ) ; } async . eachSeries ( nodes , ( node , cb ) => { var nodePath = utility . joinPath ( dirPath , node ) ; try { var stat = fsWrap . lstatSync ( nodePath ) ; } catch ( e ) { logger . warning ( 'findChanges got lstat error on node' , { category : 'sync-local-delta' , nodePath , code : e . code } ) ; throw new BlnDeltaError ( e . message ) ; } if ( utility . isExcludeFile ( node ) ) { logger . info ( 'LOCAL DELTA: ignoring file \'' + nodePath + '\' matching exclude pattern' ) ; return cb ( null ) ; } if ( utility . hasInvalidChars ( node ) ) { logger . info ( 'LOCAL DELTA: ignoring file \'' + name + '\' because filename contains invalid chars' ) ; return cb ( undefined ) ; } if ( stat . isSymbolicLink ( ) ) { logger . info ( 'LOCAL DELTA: ignoring symlink \'' + nodePath + '\'' ) ; return cb ( null ) ; } syncDb . findByIno ( stat . ino , ( err , syncedNode ) => { if ( stat . isDirectory ( ) ) { let query = { path : nodePath } ; if ( syncedNode && syncedNode . remoteId ) { query . remoteId = syncedNode . remoteId ; } ignoreDb . isIgnoredNode ( query , ( err , isIgnored ) => { if ( err ) return cb ( err ) ; if ( isIgnored ) { logger . info ( 'ignoring directory \'' + nodePath + '\' because it is ignored by ignoredNodes' , { category : 'sync-local-delta' } ) ; return cb ( null ) ; } this . analyzeNodeForChanges ( node , dirPath , oldDirPath , parentNodeId , stat , syncedNode , cb ) ; } ) ; } else { this . analyzeNodeForChanges ( node , dirPath , oldDirPath , parentNodeId , stat , syncedNode , cb ) ; } } ) ; } , callback ) ; } ) ; }
Recursively scans the given directory for new and changed nodes.
Sets the necessary localActions in the database.
Paths found in ignoreDb are ignored

@param {string} dirPath - root directory to get delta for
@param {string|undefined} oldDirPath - path of this directory after the last sync. undefined for root node
@param {string|null} parentNodeId - the id of the parent node. null for root node
@param {Function} callback - callback function
@returns {void} - no return value
Recursively scans the given directory for new and changed nodes . Sets the necessary localActions in the database . Paths found in ignoreDb are ignored