function main(blog, callback) {
  var missing = [];
  var edit = [];
  var report = [];

  Entries.each(
    blog.id,
    function (_entry, next) {
      if (_entry.deleted) return next();

      resolvePath(blog.id, _entry.path, function (err, path) {
        if (path && path !== _entry.path) {
          edit.push({ entry: _entry, path: path });
        } else if (err) {
          missing.push({ entry: _entry, path: _entry.path });
        }
        next();
      });
    },
    function (err) {
      if (err) return callback(err);

      if (!missing.length && !edit.length) {
        return callback();
      }

      if (missing.length) {
        report.push(
          missing.length +
            " files are missing from the disk for entries which are not deleted"
        );
        report.push(missing);
      }

      if (edit.length) {
        report.push(
          edit.length + "files exists on disk with a different case.."
        );
        report.push(edit);
      }

      async.eachSeries(
        edit,
        function (item, next) {
          Entry.set(blog.id, item.entry.path, { path: item.path }, next);
        },
        function (err) {
          if (err) return callback(err);

          async.eachSeries(
            missing,
            function (item, next) {
              Entry.drop(blog.id, item.entry.path, next);
            },
            function (err) {
              if (err) return callback(err);
              callback(null, report);
            }
          );
        }
      );
    }
  );
}
// if the file system is case sensitive.
if the file system is case sensitive.
if the file system is case sensitive .
function main(blog, callback) {
  var missing = [];
  var edit = [];
  var report = [];
  Entries.each(
    blog.id,
    function (_entry, next) {
      if (_entry.deleted) return next();
      resolvePath(blog.id, _entry.path, function (err, path) {
        if (path && path !== _entry.path) {
          edit.push({ entry: _entry, path: path });
        } else if (err) {
          missing.push({ entry: _entry, path: _entry.path });
        }
        next();
      });
    },
    function (err) {
      if (err) return callback(err);
      if (!missing.length && !edit.length) {
        return callback();
      }
      if (missing.length) {
        report.push(
          missing.length +
            " files are missing from the disk for entries which are not deleted"
        );
        report.push(missing);
      }
      if (edit.length) {
        report.push(
          edit.length + "files exists on disk with a different case.."
        );
        report.push(edit);
      }
      async.eachSeries(
        edit,
        function (item, next) {
          Entry.set(blog.id, item.entry.path, { path: item.path }, next);
        },
        function (err) {
          if (err) return callback(err);
          async.eachSeries(
            missing,
            function (item, next) {
              Entry.drop(blog.id, item.entry.path, next);
            },
            function (err) {
              if (err) return callback(err);
              callback(null, report);
            }
          );
        }
      );
    }
  );
}
function main ( blog , callback ) { var missing = [ ] ; var edit = [ ] ; var report = [ ] ; Entries . each ( blog . id , function ( _entry , next ) { if ( _entry . deleted ) return next ( ) ; resolvePath ( blog . id , _entry . path , function ( err , path ) { if ( path && path !== _entry . path ) { edit . push ( { entry : _entry , path : path } ) ; } else if ( err ) { missing . push ( { entry : _entry , path : _entry . path } ) ; } next ( ) ; } ) ; } , function ( err ) { if ( err ) return callback ( err ) ; if ( ! missing . length && ! edit . length ) { return callback ( ) ; } if ( missing . length ) { report . push ( missing . length + " files are missing from the disk for entries which are not deleted" ) ; report . push ( missing ) ; } if ( edit . length ) { report . push ( edit . length + "files exists on disk with a different case.." ) ; report . push ( edit ) ; } async . eachSeries ( edit , function ( item , next ) { Entry . set ( blog . id , item . entry . path , { path : item . path } , next ) ; } , function ( err ) { if ( err ) return callback ( err ) ; async . eachSeries ( missing , function ( item , next ) { Entry . drop ( blog . id , item . entry . path , next ) ; } , function ( err ) { if ( err ) return callback ( err ) ; callback ( null , report ) ; } ) ; } ) ; } ) ; }
if the file system is case sensitive.
if the file system is case sensitive .