         setTimeout tryAgain, 100
     else
         callback null
+


FETCH_AT_ONCE_FOR_REINDEX = BATCH_SIZE

# indexfield added to all documents
# @TODO: figure out a way to add a common date field
commonIndexFields =
    "docType": filter: true, searchable: false
    "tags":    filter: true

# prevent from adding or removing doc while
# a cleanup is in progress (cause fatal exception)
forgetDoc = locker.wrap 'indexfile', indexer.forget
addBatch  = locker.wrap 'indexfile', indexer.addBatch
cleanup   = locker.wrap 'indexfile', indexer.cleanup

###*
# Initialize the indexer

    process.env.INDEXES_PATH ?= path.join persistentDirectory, 'indexes'

indexer = require 'cozy-indexer'
async = require 'async'
log =  require('printit')
    date: true
    prefix: 'indexer'

locker = require '../lib/locker'
db = require('../helpers/db_connect_helper').db_connect()

indexQueue = {}
batchInProgress = false
