         filePaths = @getPaths filePath
 
         putFileDocument = (newDoc) ->
+
+            # Finally, update local file document
             pouch.db.put newDoc, (err, res) ->
                 if err
                     callback err

                    saveBinaryDocument newDoc

        updateFileInformation = (existingDoc, newDoc) ->
            newDoc._id = existingDoc._id
            newDoc._rev = existingDoc._rev
            newDoc.creationDate = existingDoc.creationDate


        populateBinaryInformation = (newDoc) ->
            if newDoc.binary?
                # Get the ID and the revision of the remote binary document
                # (since binary documents are not synchronized with the local
                # pouchDB)
                binary.getRemoteDoc newDoc.binary.file.id, (err, binaryDoc) ->
                    uploadBinary newDoc, binaryDoc
            else
                # If binary does not exist remotely yet, we have to
                # create an empty binary document remotely to have
                # an ID and a revision
                binary.createEmptyRemoteDoc (err, binaryDoc) ->
                    uploadBinary newDoc, binaryDoc

        checkFileExistence = (newDoc) ->

            # Get the existing file (if exists) to prefill
            # document with its information
            pouch.allFiles false, (err, existingDocs) ->
                if err and err.status isnt 404
                    callback err
