             callback err
 
 
-    runReplication: (fromRemote, toRemote, continuous, rebuildFs, fetchBinary, callback) ->
+    runReplication: (fromRemote, toRemote, continuous,
+                     rebuildFs, fetchBinary, callback) ->
         deviceName = config.getDeviceName()
         continuous ?= false
         rebuildFs ?= false


module.exports =

    registerDevice: (options, callback) ->
        client = request.newClient options.url
        client.setBasicAuth 'owner', options.password

        data = login: options.deviceName
        client.postAsync('device/', data)
        .then (res, body) ->
            callback null,
                id: body.id
                password: body.password
        .catch (err) ->
            log.error err.toString()
            console.error err
            callback err


    unregisterDevice: (options, callback) ->
        client = request.newClient options.url
        client.setBasicAuth 'owner', options.password

            or (info.direction is 'pull' and info.change.docs_written > 0)
                needTreeRebuild = rebuildFs

            log.info changeMessage

        onUptoDate = (info) ->
            log.info 'Replication is complete'
            if needTreeRebuild
                log.info 'Applying changes on the filesystem'
                applyChanges ->
                    needTreeRebuild = false

        onComplete = (info) ->
            log.info 'Replication is complete'
            if fromRemote and not toRemote
                log.info 'Applying changes on the filesystem'
