mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 02:00:10 +02:00
Merge pull request #5367 from overleaf/jpa-node-handle-callback-err
[misc] fix eslint violations for node/handle-callback-err GitOrigin-RevId: 83a4900e8861010df1917bff49382bd9c93375bd
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
"rules": {
|
||||
// TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671)
|
||||
// START of temporary overrides
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
"node/no-callback-literal": "off",
|
||||
"node/no-path-concat": "off",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
max-len,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -20,7 +19,7 @@ const logger = require('logger-sharelatex')
|
||||
module.exports = MessageManager = {
|
||||
createMessage(room_id, user_id, content, timestamp, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, message) {}
|
||||
callback = function () {}
|
||||
}
|
||||
let newMessageOpts = {
|
||||
content,
|
||||
@@ -40,7 +39,7 @@ module.exports = MessageManager = {
|
||||
|
||||
getMessages(room_id, limit, before, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, messages) {}
|
||||
callback = function () {}
|
||||
}
|
||||
let query = { room_id }
|
||||
if (before != null) {
|
||||
@@ -56,7 +55,7 @@ module.exports = MessageManager = {
|
||||
|
||||
findAllMessagesInRooms(room_ids, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, messages) {}
|
||||
callback = function () {}
|
||||
}
|
||||
db.messages
|
||||
.find({
|
||||
@@ -67,7 +66,7 @@ module.exports = MessageManager = {
|
||||
|
||||
deleteAllMessagesInRoom(room_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
db.messages.deleteMany(
|
||||
{
|
||||
@@ -79,7 +78,7 @@ module.exports = MessageManager = {
|
||||
|
||||
updateMessage(room_id, message_id, content, timestamp, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, message) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const query = this._ensureIdsAreObjectIds({
|
||||
_id: message_id,
|
||||
@@ -99,7 +98,7 @@ module.exports = MessageManager = {
|
||||
|
||||
deleteMessage(room_id, message_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const query = this._ensureIdsAreObjectIds({
|
||||
_id: message_id,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
max-len,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -22,7 +21,7 @@ module.exports = ThreadManager = {
|
||||
findOrCreateThread(project_id, thread_id, callback) {
|
||||
let query, update
|
||||
if (callback == null) {
|
||||
callback = function (error, thread) {}
|
||||
callback = function () {}
|
||||
}
|
||||
project_id = ObjectId(project_id.toString())
|
||||
if (thread_id !== ThreadManager.GLOBAL_THREAD) {
|
||||
@@ -63,7 +62,7 @@ module.exports = ThreadManager = {
|
||||
|
||||
findAllThreadRooms(project_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, rooms) {}
|
||||
callback = function () {}
|
||||
}
|
||||
db.rooms
|
||||
.find(
|
||||
@@ -81,7 +80,7 @@ module.exports = ThreadManager = {
|
||||
|
||||
resolveThread(project_id, thread_id, user_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
db.rooms.updateOne(
|
||||
{
|
||||
@@ -102,7 +101,7 @@ module.exports = ThreadManager = {
|
||||
|
||||
reopenThread(project_id, thread_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
db.rooms.updateOne(
|
||||
{
|
||||
@@ -120,7 +119,7 @@ module.exports = ThreadManager = {
|
||||
|
||||
deleteThread(project_id, thread_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, room_id) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return this.findOrCreateThread(
|
||||
project_id,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
max-len,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -55,6 +54,7 @@ describe('Getting messages', function () {
|
||||
return ChatClient.getGlobalMessages(
|
||||
this.project_id,
|
||||
(error, response, messages) => {
|
||||
if (error) return done(error)
|
||||
expect(messages.length).to.equal(2)
|
||||
messages.reverse()
|
||||
expect(messages[0].content).to.equal(this.content1)
|
||||
@@ -115,6 +115,7 @@ describe('Getting messages', function () {
|
||||
return ChatClient.getThreads(
|
||||
this.project_id,
|
||||
(error, response, threads) => {
|
||||
if (error) return done(error)
|
||||
expect(Object.keys(threads).length).to.equal(2)
|
||||
const thread1 = threads[this.thread_id1]
|
||||
expect(thread1.messages.length).to.equal(2)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
max-len,
|
||||
no-return-assign,
|
||||
node/no-deprecated-api,
|
||||
@@ -121,6 +120,7 @@ describe('Sending a message', function () {
|
||||
'malformed-user',
|
||||
'content',
|
||||
(error, response, body) => {
|
||||
if (error) return done(error)
|
||||
expect(response.statusCode).to.equal(400)
|
||||
expect(body).to.equal('Invalid user_id')
|
||||
return done()
|
||||
@@ -137,6 +137,7 @@ describe('Sending a message', function () {
|
||||
this.user_id,
|
||||
'content',
|
||||
(error, response, body) => {
|
||||
if (error) return done(error)
|
||||
expect(response.statusCode).to.equal(400)
|
||||
expect(body).to.equal('Invalid project_id')
|
||||
return done()
|
||||
@@ -153,6 +154,7 @@ describe('Sending a message', function () {
|
||||
this.user_id,
|
||||
'content',
|
||||
(error, response, body) => {
|
||||
if (error) return done(error)
|
||||
expect(response.statusCode).to.equal(400)
|
||||
expect(body).to.equal('Invalid thread_id')
|
||||
return done()
|
||||
@@ -169,6 +171,7 @@ describe('Sending a message', function () {
|
||||
this.user_id,
|
||||
null,
|
||||
(error, response, body) => {
|
||||
if (error) return done(error)
|
||||
expect(response.statusCode).to.equal(400)
|
||||
expect(body).to.equal('No content provided')
|
||||
return done()
|
||||
@@ -186,6 +189,7 @@ describe('Sending a message', function () {
|
||||
this.user_id,
|
||||
content,
|
||||
(error, response, body) => {
|
||||
if (error) return done(error)
|
||||
expect(response.statusCode).to.equal(400)
|
||||
expect(body).to.equal('Content too long (> 10240 bytes)')
|
||||
return done()
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
@@ -20,7 +17,7 @@ module.exports = {
|
||||
callbacks: [],
|
||||
ensureRunning(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (this.running) {
|
||||
return callback()
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"rules": {
|
||||
// TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671)
|
||||
// START of temporary overrides
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
"node/no-callback-literal": "off",
|
||||
"node/no-path-concat": "off",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -30,7 +29,7 @@ function isImageNameAllowed(imageName) {
|
||||
module.exports = CompileController = {
|
||||
compile(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('compile-request')
|
||||
return RequestParser.parse(req.body, function (error, request) {
|
||||
@@ -152,7 +151,7 @@ module.exports = CompileController = {
|
||||
|
||||
clearCache(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
return ProjectPersistenceManager.clearProject(
|
||||
req.params.project_id,
|
||||
@@ -168,7 +167,7 @@ module.exports = CompileController = {
|
||||
|
||||
syncFromCode(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const { file } = req.query
|
||||
const line = parseInt(req.query.line, 10)
|
||||
@@ -201,7 +200,7 @@ module.exports = CompileController = {
|
||||
|
||||
syncFromPdf(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const page = parseInt(req.query.page, 10)
|
||||
const h = parseFloat(req.query.h)
|
||||
@@ -233,7 +232,7 @@ module.exports = CompileController = {
|
||||
|
||||
wordcount(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const file = req.query.file || 'main.tex'
|
||||
const { project_id } = req.params
|
||||
@@ -262,7 +261,7 @@ module.exports = CompileController = {
|
||||
|
||||
status(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
return res.send('OK')
|
||||
},
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
@@ -23,7 +20,7 @@ module.exports = LockManager = {
|
||||
tryLock(key, callback) {
|
||||
let lockValue
|
||||
if (callback == null) {
|
||||
callback = function (err, gotLock) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const existingLock = LockState[key]
|
||||
if (existingLock != null) {
|
||||
@@ -46,7 +43,7 @@ module.exports = LockManager = {
|
||||
getLock(key, callback) {
|
||||
let attempt
|
||||
if (callback == null) {
|
||||
callback = function (error, lockValue) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const startTime = Date.now()
|
||||
return (attempt = () =>
|
||||
@@ -68,7 +65,7 @@ module.exports = LockManager = {
|
||||
|
||||
releaseLock(key, lockValue, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const existingLock = LockState[key]
|
||||
if (existingLock === lockValue) {
|
||||
@@ -93,7 +90,7 @@ module.exports = LockManager = {
|
||||
|
||||
runWithLock(key, runner, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return LockManager.getLock(key, function (error, lockValue) {
|
||||
if (error != null) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-useless-escape,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -18,7 +17,7 @@ const logger = require('logger-sharelatex')
|
||||
module.exports = DraftModeManager = {
|
||||
injectDraftMode(filename, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return fs.readFile(filename, 'utf8', function (error, content) {
|
||||
if (error != null) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -33,7 +32,7 @@ module.exports = LatexRunner = {
|
||||
runLatex(project_id, options, callback) {
|
||||
let command
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
let {
|
||||
directory,
|
||||
@@ -167,7 +166,7 @@ module.exports = LatexRunner = {
|
||||
|
||||
killLatex(project_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const id = `${project_id}`
|
||||
logger.log({ id }, 'killing running compile')
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -32,11 +31,7 @@ module.exports = CommandRunner = {
|
||||
callback
|
||||
) {
|
||||
let key, value
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
} else {
|
||||
callback = _.once(callback)
|
||||
}
|
||||
callback = _.once(callback)
|
||||
command = Array.from(command).map(arg =>
|
||||
arg.toString().replace('$COMPILE_DIR', directory)
|
||||
)
|
||||
@@ -91,7 +86,7 @@ module.exports = CommandRunner = {
|
||||
|
||||
kill(pid, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
try {
|
||||
process.kill(-pid) // kill all processes in group
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -25,7 +24,7 @@ module.exports = LockManager = {
|
||||
|
||||
runWithLock(path, runner, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const lockOpts = {
|
||||
wait: this.MAX_LOCK_WAIT_TIME,
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
@@ -52,7 +49,7 @@ module.exports = OutputCacheManager = {
|
||||
generateBuildId(callback) {
|
||||
// generate a secure build id from Date.now() and 8 random bytes in hex
|
||||
if (callback == null) {
|
||||
callback = function (error, buildId) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return crypto.randomBytes(8, function (err, buf) {
|
||||
if (err != null) {
|
||||
@@ -72,7 +69,7 @@ module.exports = OutputCacheManager = {
|
||||
callback
|
||||
) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return OutputCacheManager.generateBuildId(function (err, buildId) {
|
||||
if (err != null) {
|
||||
@@ -122,7 +119,7 @@ module.exports = OutputCacheManager = {
|
||||
// make a compileDir/CACHE_SUBDIR/build_id directory and
|
||||
// copy all the output files into it
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const cacheRoot = Path.join(outputDir, OutputCacheManager.CACHE_SUBDIR)
|
||||
// Put the files into a new cache subdirectory
|
||||
@@ -339,6 +336,7 @@ module.exports = OutputCacheManager = {
|
||||
return callback(err)
|
||||
}
|
||||
fs.readdir(contentRoot, function (err, results) {
|
||||
if (err) return callback(err)
|
||||
const dirs = results.sort()
|
||||
const contentId = dirs.find(dir =>
|
||||
OutputCacheManager.BUILD_REGEX.test(dir)
|
||||
@@ -366,7 +364,7 @@ module.exports = OutputCacheManager = {
|
||||
|
||||
archiveLogs(outputFiles, compileDir, outputDir, buildId, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const archiveDir = Path.join(
|
||||
outputDir,
|
||||
@@ -417,7 +415,7 @@ module.exports = OutputCacheManager = {
|
||||
expireOutputFiles(cacheRoot, options, callback) {
|
||||
// look in compileDir for build dirs and delete if > N or age of mod time > T
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return fs.readdir(cacheRoot, function (err, results) {
|
||||
if (err != null) {
|
||||
@@ -481,7 +479,7 @@ module.exports = OutputCacheManager = {
|
||||
_checkFileIsSafe(src, callback) {
|
||||
// check if we have a valid file to copy into the cache
|
||||
if (callback == null) {
|
||||
callback = function (error, isSafe) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return fs.stat(src, function (err, stats) {
|
||||
if ((err != null ? err.code : undefined) === 'ENOENT') {
|
||||
@@ -537,7 +535,7 @@ module.exports = OutputCacheManager = {
|
||||
|
||||
_checkIfShouldCopy(src, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (err, shouldCopy) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return callback(null, !Path.basename(src).match(/^strace/))
|
||||
},
|
||||
@@ -545,7 +543,7 @@ module.exports = OutputCacheManager = {
|
||||
_checkIfShouldArchive(src, callback) {
|
||||
let needle
|
||||
if (callback == null) {
|
||||
callback = function (err, shouldCopy) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (Path.basename(src).match(/^strace/)) {
|
||||
return callback(null, true)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-undef,
|
||||
no-unused-vars,
|
||||
@@ -26,7 +25,7 @@ module.exports = OutputFileOptimiser = {
|
||||
// check output file (src) and see if we can optimise it, storing
|
||||
// the result in the build directory (dst)
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (src.match(/\/output\.pdf$/)) {
|
||||
return OutputFileOptimiser.checkIfPDFIsOptimised(
|
||||
@@ -68,7 +67,7 @@ module.exports = OutputFileOptimiser = {
|
||||
|
||||
optimisePDF(src, dst, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const tmpOutput = dst + '.opt'
|
||||
const args = ['--linearize', '--newline-before-endstream', src, tmpOutput]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -94,7 +93,11 @@ module.exports = ProjectPersistenceManager = {
|
||||
() => {
|
||||
setInterval(() => {
|
||||
ProjectPersistenceManager.refreshExpiryTimeout(() => {
|
||||
ProjectPersistenceManager.clearExpiredProjects()
|
||||
ProjectPersistenceManager.clearExpiredProjects(err => {
|
||||
if (err) {
|
||||
logger.error({ err }, 'clearing expired projects failed')
|
||||
}
|
||||
})
|
||||
})
|
||||
}, 10 * 60 * 1000)
|
||||
}
|
||||
@@ -109,7 +112,7 @@ module.exports = ProjectPersistenceManager = {
|
||||
|
||||
clearExpiredProjects(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return ProjectPersistenceManager._findExpiredProjectIds(function (
|
||||
error,
|
||||
@@ -139,7 +142,7 @@ module.exports = ProjectPersistenceManager = {
|
||||
}
|
||||
return CompileManager.clearExpiredProjects(
|
||||
ProjectPersistenceManager.EXPIRY_TIMEOUT,
|
||||
error => callback()
|
||||
error => callback(error)
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -147,7 +150,7 @@ module.exports = ProjectPersistenceManager = {
|
||||
|
||||
clearProject(project_id, user_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
logger.log({ project_id, user_id }, 'clearing project for user')
|
||||
return CompileManager.clearProject(project_id, user_id, function (error) {
|
||||
@@ -168,7 +171,7 @@ module.exports = ProjectPersistenceManager = {
|
||||
|
||||
clearProjectFromCache(project_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
logger.log({ project_id }, 'clearing project from cache')
|
||||
return UrlCache.clearProject(project_id, function (error) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-control-regex,
|
||||
no-throw-literal,
|
||||
no-unused-vars,
|
||||
@@ -26,7 +25,7 @@ module.exports = RequestParser = {
|
||||
parse(body, callback) {
|
||||
let resource
|
||||
if (callback == null) {
|
||||
callback = function (error, data) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const response = {}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
no-useless-escape,
|
||||
@@ -30,7 +29,7 @@ const parallelFileDownloads = settings.parallelFileDownloads || 1
|
||||
module.exports = ResourceWriter = {
|
||||
syncResourcesToDisk(request, basePath, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, resourceList) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (request.syncType === 'incremental') {
|
||||
logger.log(
|
||||
@@ -111,7 +110,7 @@ module.exports = ResourceWriter = {
|
||||
|
||||
saveIncrementalResourcesToDisk(project_id, resources, basePath, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return this._createDirectory(basePath, error => {
|
||||
if (error != null) {
|
||||
@@ -129,7 +128,7 @@ module.exports = ResourceWriter = {
|
||||
|
||||
saveAllResourcesToDisk(project_id, resources, basePath, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return this._createDirectory(basePath, error => {
|
||||
if (error != null) {
|
||||
@@ -157,7 +156,7 @@ module.exports = ResourceWriter = {
|
||||
|
||||
_createDirectory(basePath, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return fs.mkdir(basePath, function (err) {
|
||||
if (err != null) {
|
||||
@@ -175,7 +174,7 @@ module.exports = ResourceWriter = {
|
||||
|
||||
_removeExtraneousFiles(resources, basePath, _callback) {
|
||||
if (_callback == null) {
|
||||
_callback = function (error, outputFiles, allFiles) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('unlink-output-files')
|
||||
const callback = function (error, ...result) {
|
||||
@@ -267,7 +266,7 @@ module.exports = ResourceWriter = {
|
||||
|
||||
_deleteFileIfNotDirectory(path, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return fs.stat(path, function (error, stat) {
|
||||
if (error != null && error.code === 'ENOENT') {
|
||||
@@ -298,7 +297,7 @@ module.exports = ResourceWriter = {
|
||||
|
||||
_writeResourceToDisk(project_id, resource, basePath, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return ResourceWriter.checkPath(
|
||||
basePath,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
node/no-deprecated-api,
|
||||
*/
|
||||
@@ -22,7 +21,7 @@ module.exports = SafeReader = {
|
||||
|
||||
readFile(file, size, encoding, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, result) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return fs.open(file, 'r', function (err, fd) {
|
||||
if (err != null && err.code === 'ENOENT') {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -26,7 +25,7 @@ module.exports = TikzManager = {
|
||||
checkMainFile(compileDir, mainFile, resources, callback) {
|
||||
// if there's already an output.tex file, we don't want to touch it
|
||||
if (callback == null) {
|
||||
callback = function (error, needsMainFile) {}
|
||||
callback = function () {}
|
||||
}
|
||||
for (const resource of Array.from(resources)) {
|
||||
if (resource.path === 'output.tex') {
|
||||
@@ -70,7 +69,7 @@ module.exports = TikzManager = {
|
||||
|
||||
injectOutputFile(compileDir, mainFile, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return ResourceWriter.checkPath(
|
||||
compileDir,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
node/no-deprecated-api,
|
||||
@@ -33,7 +32,7 @@ module.exports = UrlFetcher = {
|
||||
|
||||
pipeUrlToFile(url, filePath, _callback) {
|
||||
if (_callback == null) {
|
||||
_callback = function (error) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const callbackOnce = function (error) {
|
||||
if (timeoutHandler != null) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-path-concat,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
@@ -42,7 +41,7 @@ const MOCHA_LATEX_TIMEOUT = 60 * 1000
|
||||
|
||||
const convertToPng = function (pdfPath, pngPath, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const command = `convert ${fixturePath(pdfPath)} ${fixturePath(pngPath)}`
|
||||
console.log('COMMAND')
|
||||
@@ -56,7 +55,7 @@ const convertToPng = function (pdfPath, pngPath, callback) {
|
||||
|
||||
const compare = function (originalPath, generatedPath, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, same) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const diff_file = `${fixturePath(generatedPath)}-diff.png`
|
||||
const proc = ChildProcess.exec(
|
||||
@@ -84,7 +83,7 @@ const compare = function (originalPath, generatedPath, callback) {
|
||||
|
||||
const checkPdfInfo = function (pdfPath, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, output) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const proc = ChildProcess.exec(`pdfinfo ${fixturePath(pdfPath)}`)
|
||||
let stdout = ''
|
||||
@@ -101,7 +100,7 @@ const checkPdfInfo = function (pdfPath, callback) {
|
||||
|
||||
const compareMultiplePages = function (project_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
function compareNext(page_no, callback) {
|
||||
const path = `tmp/${project_id}-source-${page_no}.png`
|
||||
@@ -128,7 +127,7 @@ const compareMultiplePages = function (project_id, callback) {
|
||||
|
||||
const comparePdf = function (project_id, example_dir, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
console.log('CONVERT')
|
||||
console.log(`tmp/${project_id}.pdf`, `tmp/${project_id}-generated.png`)
|
||||
@@ -184,7 +183,7 @@ const downloadAndComparePdf = function (
|
||||
callback
|
||||
) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const writeStream = fs.createWriteStream(fixturePath(`tmp/${project_id}.pdf`))
|
||||
request.get(url).pipe(writeStream)
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
@@ -55,6 +52,7 @@ Hello world
|
||||
it('should provide the pdf for download', function (done) {
|
||||
const pdf = Client.getOutputFile(this.body, 'pdf')
|
||||
return request.get(pdf.url, (error, res, body) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(200)
|
||||
return done()
|
||||
})
|
||||
@@ -63,6 +61,7 @@ Hello world
|
||||
return it('should provide the log for download', function (done) {
|
||||
const log = Client.getOutputFile(this.body, 'pdf')
|
||||
return request.get(log.url, (error, res, body) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(200)
|
||||
return done()
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -28,7 +27,7 @@ module.exports = Client = {
|
||||
|
||||
compile(project_id, data, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, res, body) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (data) {
|
||||
// Enable pdf caching unless disabled explicitly.
|
||||
@@ -47,7 +46,7 @@ module.exports = Client = {
|
||||
|
||||
clearCache(project_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, res, body) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return request.del(`${this.host}/project/${project_id}`, callback)
|
||||
},
|
||||
@@ -78,7 +77,7 @@ module.exports = Client = {
|
||||
|
||||
syncFromCodeWithImage(project_id, file, line, column, imageName, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, pdfPositions) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return request.get(
|
||||
{
|
||||
@@ -109,7 +108,7 @@ module.exports = Client = {
|
||||
|
||||
syncFromPdfWithImage(project_id, page, h, v, imageName, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, pdfPositions) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return request.get(
|
||||
{
|
||||
@@ -136,7 +135,7 @@ module.exports = Client = {
|
||||
|
||||
compileDirectory(project_id, baseDirectory, directory, serverPort, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, res, body) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const resources = []
|
||||
let entities = fs.readdirSync(`${baseDirectory}/${directory}`)
|
||||
@@ -213,7 +212,7 @@ module.exports = Client = {
|
||||
|
||||
wordcountWithImage(project_id, file, image, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, pdfPositions) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return request.get(
|
||||
{
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
@@ -23,7 +20,7 @@ module.exports = {
|
||||
callbacks: [],
|
||||
ensureRunning(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (this.running) {
|
||||
return callback()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -195,7 +194,7 @@ describe('DockerRunner', function () {
|
||||
callback
|
||||
) => {
|
||||
if (callback == null) {
|
||||
callback = function (error, output) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (firstTime) {
|
||||
firstTime = false
|
||||
@@ -615,6 +614,7 @@ describe('DockerRunner', function () {
|
||||
return this.DockerRunner.startContainer(
|
||||
this.options,
|
||||
this.volumes,
|
||||
() => {},
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
@@ -676,7 +676,7 @@ describe('DockerRunner', function () {
|
||||
beforeEach(function (done) {
|
||||
this.container.wait = function (callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, exitCode) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return setTimeout(() => callback(null, { StatusCode: 42 }), 100)
|
||||
}
|
||||
@@ -779,6 +779,7 @@ describe('DockerRunner', function () {
|
||||
this.containerId,
|
||||
false,
|
||||
err => {
|
||||
if (err) return done(err)
|
||||
this.Docker.prototype.getContainer.callCount.should.equal(1)
|
||||
this.Docker.prototype.getContainer
|
||||
.calledWith(this.containerId)
|
||||
@@ -793,6 +794,7 @@ describe('DockerRunner', function () {
|
||||
this.containerId,
|
||||
true,
|
||||
err => {
|
||||
if (err) return done(err)
|
||||
this.fakeContainer.remove.callCount.should.equal(1)
|
||||
this.fakeContainer.remove
|
||||
.calledWith({ force: true, v: true })
|
||||
@@ -807,6 +809,7 @@ describe('DockerRunner', function () {
|
||||
this.containerId,
|
||||
false,
|
||||
err => {
|
||||
if (err) return done(err)
|
||||
this.fakeContainer.remove.callCount.should.equal(1)
|
||||
this.fakeContainer.remove
|
||||
.calledWith({ force: false, v: true })
|
||||
@@ -888,6 +891,7 @@ describe('DockerRunner', function () {
|
||||
|
||||
it('should get the container', function (done) {
|
||||
return this.DockerRunner.kill(this.containerId, err => {
|
||||
if (err) return done(err)
|
||||
this.Docker.prototype.getContainer.callCount.should.equal(1)
|
||||
this.Docker.prototype.getContainer
|
||||
.calledWith(this.containerId)
|
||||
@@ -898,6 +902,7 @@ describe('DockerRunner', function () {
|
||||
|
||||
it('should try to force-destroy the container', function (done) {
|
||||
return this.DockerRunner.kill(this.containerId, err => {
|
||||
if (err) return done(err)
|
||||
this.fakeContainer.kill.callCount.should.equal(1)
|
||||
return done()
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -36,7 +35,7 @@ describe('OutputFileFinder', function () {
|
||||
})
|
||||
|
||||
describe('findOutputFiles', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
this.resource_path = 'resource/path.tex'
|
||||
this.output_paths = ['output.pdf', 'extra/file.tex']
|
||||
this.all_paths = this.output_paths.concat([this.resource_path])
|
||||
@@ -48,7 +47,9 @@ describe('OutputFileFinder', function () {
|
||||
this.resources,
|
||||
this.directory,
|
||||
(error, outputFiles) => {
|
||||
if (error) return done(error)
|
||||
this.outputFiles = outputFiles
|
||||
done()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -89,10 +88,12 @@ describe('RequestParser', function () {
|
||||
})
|
||||
|
||||
describe('without a compiler specified', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
delete this.validRequest.compile.options.compiler
|
||||
return this.RequestParser.parse(this.validRequest, (error, data) => {
|
||||
if (error) return done(error)
|
||||
this.data = data
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -102,9 +103,11 @@ describe('RequestParser', function () {
|
||||
})
|
||||
|
||||
describe('with imageName set', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
return this.RequestParser.parse(this.validRequest, (error, data) => {
|
||||
if (error) return done(error)
|
||||
this.data = data
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -156,10 +159,12 @@ describe('RequestParser', function () {
|
||||
})
|
||||
|
||||
describe('with flags set', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
this.validRequest.compile.options.flags = ['-file-line-error']
|
||||
return this.RequestParser.parse(this.validRequest, (error, data) => {
|
||||
if (error) return done(error)
|
||||
this.data = data
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -169,9 +174,11 @@ describe('RequestParser', function () {
|
||||
})
|
||||
|
||||
describe('with flags not specified', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
return this.RequestParser.parse(this.validRequest, (error, data) => {
|
||||
if (error) return done(error)
|
||||
this.data = data
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -181,10 +188,12 @@ describe('RequestParser', function () {
|
||||
})
|
||||
|
||||
describe('without a timeout specified', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
delete this.validRequest.compile.options.timeout
|
||||
return this.RequestParser.parse(this.validRequest, (error, data) => {
|
||||
if (error) return done(error)
|
||||
this.data = data
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -196,11 +205,13 @@ describe('RequestParser', function () {
|
||||
})
|
||||
|
||||
describe('with a timeout larger than the maximum', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
this.validRequest.compile.options.timeout =
|
||||
this.RequestParser.MAX_TIMEOUT + 1
|
||||
return this.RequestParser.parse(this.validRequest, (error, data) => {
|
||||
if (error) return done(error)
|
||||
this.data = data
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -212,9 +223,11 @@ describe('RequestParser', function () {
|
||||
})
|
||||
|
||||
describe('with a timeout', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
return this.RequestParser.parse(this.validRequest, (error, data) => {
|
||||
if (error) return done(error)
|
||||
this.data = data
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"rules": {
|
||||
// TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671)
|
||||
// START of temporary overrides
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
"node/no-callback-literal": "off",
|
||||
"node/no-path-concat": "off",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -18,7 +17,7 @@ const metrics = require('@overleaf/metrics')
|
||||
module.exports = ContactManager = {
|
||||
touchContact(user_id, contact_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
try {
|
||||
user_id = ObjectId(user_id.toString())
|
||||
@@ -45,7 +44,7 @@ module.exports = ContactManager = {
|
||||
|
||||
getContacts(user_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
try {
|
||||
user_id = ObjectId(user_id.toString())
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
@@ -21,7 +18,7 @@ module.exports = {
|
||||
callbacks: [],
|
||||
ensureRunning(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (this.running) {
|
||||
return callback()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-undef,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -36,6 +35,7 @@ describe('Getting Contacts', function () {
|
||||
json: true,
|
||||
},
|
||||
(error, response, body) => {
|
||||
if (error) return done(error)
|
||||
response.statusCode.should.equal(200)
|
||||
body.contact_ids.should.deep.equal([])
|
||||
return done()
|
||||
@@ -84,6 +84,7 @@ describe('Getting Contacts', function () {
|
||||
json: true,
|
||||
},
|
||||
(error, response, body) => {
|
||||
if (error) return done(error)
|
||||
response.statusCode.should.equal(200)
|
||||
body.contact_ids.should.deep.equal([
|
||||
this.contact_id_2,
|
||||
@@ -103,6 +104,7 @@ describe('Getting Contacts', function () {
|
||||
json: true,
|
||||
},
|
||||
(error, response, body) => {
|
||||
if (error) return done(error)
|
||||
response.statusCode.should.equal(200)
|
||||
body.contact_ids.should.deep.equal([
|
||||
this.contact_id_2,
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"rules": {
|
||||
// TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671)
|
||||
// START of temporary overrides
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
"node/no-callback-literal": "off",
|
||||
"node/no-path-concat": "off",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-dupe-keys,
|
||||
no-undef,
|
||||
*/
|
||||
@@ -31,7 +30,7 @@ module.exports = DocManager = {
|
||||
filter = {}
|
||||
}
|
||||
if (callback == null) {
|
||||
callback = function (error, doc) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (filter.inS3 !== true) {
|
||||
return callback('must include inS3 when getting doc')
|
||||
@@ -102,7 +101,7 @@ module.exports = DocManager = {
|
||||
|
||||
getFullDoc(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (err, doc) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return DocManager._getDoc(
|
||||
project_id,
|
||||
@@ -190,7 +189,7 @@ module.exports = DocManager = {
|
||||
|
||||
getDocLines(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (err, doc) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return DocManager._getDoc(
|
||||
project_id,
|
||||
@@ -211,7 +210,7 @@ module.exports = DocManager = {
|
||||
|
||||
getAllNonDeletedDocs(project_id, filter, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, docs) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return DocArchive.unArchiveAllDocs(project_id, function (error) {
|
||||
if (error != null) {
|
||||
@@ -238,7 +237,7 @@ module.exports = DocManager = {
|
||||
|
||||
updateDoc(project_id, doc_id, lines, version, ranges, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, modified, rev) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (lines == null || version == null || ranges == null) {
|
||||
return callback(new Error('no lines, version or ranges provided'))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
valid-typeof,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -22,7 +21,7 @@ const Settings = require('@overleaf/settings')
|
||||
module.exports = HttpController = {
|
||||
getDoc(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const { project_id } = req.params
|
||||
const { doc_id } = req.params
|
||||
@@ -73,7 +72,7 @@ module.exports = HttpController = {
|
||||
|
||||
getRawDoc(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const { project_id } = req.params
|
||||
const { doc_id } = req.params
|
||||
@@ -93,7 +92,7 @@ module.exports = HttpController = {
|
||||
|
||||
getAllDocs(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const { project_id } = req.params
|
||||
logger.log({ project_id }, 'getting all docs')
|
||||
@@ -137,7 +136,7 @@ module.exports = HttpController = {
|
||||
|
||||
getAllRanges(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const { project_id } = req.params
|
||||
logger.log({ project_id }, 'getting all ranges')
|
||||
@@ -158,7 +157,7 @@ module.exports = HttpController = {
|
||||
|
||||
updateDoc(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const { project_id } = req.params
|
||||
const { doc_id } = req.params
|
||||
@@ -266,7 +265,7 @@ module.exports = HttpController = {
|
||||
|
||||
archiveAllDocs(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const { project_id } = req.params
|
||||
logger.log({ project_id }, 'archiving all docs')
|
||||
@@ -291,7 +290,7 @@ module.exports = HttpController = {
|
||||
|
||||
unArchiveAllDocs(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const { project_id } = req.params
|
||||
logger.log({ project_id }, 'unarchiving all docs')
|
||||
@@ -305,7 +304,7 @@ module.exports = HttpController = {
|
||||
|
||||
destroyAllDocs(req, res, next) {
|
||||
if (next == null) {
|
||||
next = function (error) {}
|
||||
next = function () {}
|
||||
}
|
||||
const { project_id } = req.params
|
||||
logger.log({ project_id }, 'destroying all docs')
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -21,7 +20,7 @@ const { promisify } = require('util')
|
||||
module.exports = MongoManager = {
|
||||
findDoc(project_id, doc_id, filter, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, doc) {}
|
||||
callback = function () {}
|
||||
}
|
||||
db.docs.findOne(
|
||||
{
|
||||
@@ -141,7 +140,7 @@ module.exports = MongoManager = {
|
||||
|
||||
getDocVersion(doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, version) {}
|
||||
callback = function () {}
|
||||
}
|
||||
db.docOps.findOne(
|
||||
{
|
||||
@@ -163,7 +162,7 @@ module.exports = MongoManager = {
|
||||
|
||||
setDocVersion(doc_id, version, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
db.docOps.updateOne(
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -78,6 +77,7 @@ describe('Archiving', function () {
|
||||
throw error
|
||||
}
|
||||
return DocstoreClient.archiveAllDoc(this.project_id, (error, res) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
return done()
|
||||
})
|
||||
@@ -94,6 +94,7 @@ describe('Archiving', function () {
|
||||
(doc => {
|
||||
return callback => {
|
||||
return db.docs.findOne({ _id: doc._id }, (error, doc) => {
|
||||
if (error) return callback(error)
|
||||
expect(doc.lines).not.to.exist
|
||||
expect(doc.ranges).not.to.exist
|
||||
doc.inS3.should.equal(true)
|
||||
@@ -113,6 +114,7 @@ describe('Archiving', function () {
|
||||
this.project_id,
|
||||
doc._id,
|
||||
(error, s3_doc) => {
|
||||
if (error) return callback(error)
|
||||
s3_doc.lines.should.deep.equal(doc.lines)
|
||||
s3_doc.ranges.should.deep.equal(doc.ranges)
|
||||
callback()
|
||||
@@ -151,6 +153,7 @@ describe('Archiving', function () {
|
||||
((doc, i) => {
|
||||
return callback => {
|
||||
return db.docs.findOne({ _id: doc._id }, (error, doc) => {
|
||||
if (error) return callback(error)
|
||||
doc.lines.should.deep.equal(this.docs[i].lines)
|
||||
doc.ranges.should.deep.equal(this.docs[i].ranges)
|
||||
expect(doc.inS3).not.to.exist
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -59,6 +58,7 @@ function deleteTestSuite(deleteDoc) {
|
||||
describe('when the doc exists', function () {
|
||||
beforeEach(function (done) {
|
||||
deleteDoc(this.project_id, this.doc_id, (error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
return done()
|
||||
})
|
||||
@@ -83,6 +83,7 @@ function deleteTestSuite(deleteDoc) {
|
||||
|
||||
it('should insert a deleted doc into the docs collection', function (done) {
|
||||
return db.docs.find({ _id: this.doc_id }).toArray((error, docs) => {
|
||||
if (error) return done(error)
|
||||
docs[0]._id.should.deep.equal(this.doc_id)
|
||||
docs[0].lines.should.deep.equal(this.lines)
|
||||
docs[0].deleted.should.equal(true)
|
||||
@@ -112,6 +113,7 @@ function deleteTestSuite(deleteDoc) {
|
||||
|
||||
beforeEach('delete Doc', function (done) {
|
||||
deleteDoc(this.project_id, this.doc_id, (error, res) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
done()
|
||||
})
|
||||
@@ -196,6 +198,7 @@ function deleteTestSuite(deleteDoc) {
|
||||
return it('should return a 404', function (done) {
|
||||
const missing_doc_id = ObjectId()
|
||||
deleteDoc(this.project_id, missing_doc_id, (error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(404)
|
||||
return done()
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -70,6 +69,7 @@ describe('Getting all docs', function () {
|
||||
version,
|
||||
this.deleted_doc.ranges,
|
||||
err => {
|
||||
if (err) return done(err)
|
||||
return DocstoreClient.deleteDoc(
|
||||
this.project_id,
|
||||
this.deleted_doc._id,
|
||||
|
||||
@@ -61,6 +61,7 @@ describe('Getting A Doc from Archive', function () {
|
||||
this.doc._id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(200)
|
||||
res.headers['x-doc-status'].should.equal('archived')
|
||||
doc.lines.should.deep.equal(this.doc.lines)
|
||||
@@ -77,6 +78,7 @@ describe('Getting A Doc from Archive', function () {
|
||||
this.doc._id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(200)
|
||||
res.headers['x-doc-status'].should.equal('archived')
|
||||
doc.lines.should.deep.equal(this.doc.lines)
|
||||
@@ -113,6 +115,7 @@ describe('Getting A Doc from Archive', function () {
|
||||
this.doc._id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(200)
|
||||
res.headers['x-doc-status'].should.equal('active')
|
||||
doc.lines.should.deep.equal(this.doc.lines)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -59,6 +58,7 @@ describe('Getting a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.lines)
|
||||
doc.version.should.equal(this.version)
|
||||
doc.ranges.should.deep.equal(this.ranges)
|
||||
@@ -76,6 +76,7 @@ describe('Getting a doc', function () {
|
||||
missing_doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(404)
|
||||
return done()
|
||||
}
|
||||
@@ -111,6 +112,7 @@ describe('Getting a doc', function () {
|
||||
this.deleted_doc_id,
|
||||
{ include_deleted: true },
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.lines)
|
||||
doc.version.should.equal(this.version)
|
||||
doc.ranges.should.deep.equal(this.ranges)
|
||||
@@ -126,6 +128,7 @@ describe('Getting a doc', function () {
|
||||
this.deleted_doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(404)
|
||||
return done()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -73,6 +72,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.body = body
|
||||
return done()
|
||||
}
|
||||
@@ -89,6 +89,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.originalLines)
|
||||
doc.version.should.equal(this.version)
|
||||
doc.ranges.should.deep.equal(this.originalRanges)
|
||||
@@ -107,6 +108,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.body = body
|
||||
return done()
|
||||
}
|
||||
@@ -127,6 +129,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.newLines)
|
||||
doc.version.should.equal(this.version)
|
||||
doc.ranges.should.deep.equal(this.originalRanges)
|
||||
@@ -145,6 +148,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version + 1,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.body = body
|
||||
return done()
|
||||
}
|
||||
@@ -165,6 +169,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.originalLines)
|
||||
doc.version.should.equal(this.version + 1)
|
||||
doc.ranges.should.deep.equal(this.originalRanges)
|
||||
@@ -183,6 +188,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version,
|
||||
this.newRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.body = body
|
||||
return done()
|
||||
}
|
||||
@@ -203,6 +209,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.originalLines)
|
||||
doc.version.should.equal(this.version)
|
||||
doc.ranges.should.deep.equal(this.newRanges)
|
||||
@@ -222,6 +229,7 @@ describe('Applying updates to a doc', function () {
|
||||
0,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.body = body
|
||||
return done()
|
||||
@@ -239,6 +247,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.missing_doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.originalLines)
|
||||
doc.version.should.equal(0)
|
||||
doc.ranges.should.deep.equal(this.originalRanges)
|
||||
@@ -258,6 +267,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.body = body
|
||||
return done()
|
||||
@@ -275,6 +285,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.originalLines)
|
||||
return done()
|
||||
}
|
||||
@@ -291,6 +302,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.body = body
|
||||
return done()
|
||||
@@ -308,6 +320,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.originalLines)
|
||||
return done()
|
||||
}
|
||||
@@ -325,6 +338,7 @@ describe('Applying updates to a doc', function () {
|
||||
null,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.body = body
|
||||
return done()
|
||||
@@ -342,6 +356,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.originalLines)
|
||||
doc.version.should.equal(this.version)
|
||||
return done()
|
||||
@@ -361,6 +376,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.body = body
|
||||
return done()
|
||||
}
|
||||
@@ -377,6 +393,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.largeLines)
|
||||
return done()
|
||||
}
|
||||
@@ -398,6 +415,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.body = body
|
||||
return done()
|
||||
@@ -415,6 +433,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.largeLines)
|
||||
return done()
|
||||
}
|
||||
@@ -433,6 +452,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.body = body
|
||||
return done()
|
||||
@@ -454,6 +474,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.originalLines)
|
||||
return done()
|
||||
}
|
||||
@@ -475,6 +496,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.version,
|
||||
this.originalRanges,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.body = body
|
||||
return done()
|
||||
@@ -488,6 +510,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.doc_id,
|
||||
{},
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.originalLines)
|
||||
return done()
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = {
|
||||
callbacks: [],
|
||||
ensureRunning(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (this.running) {
|
||||
return callback()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-dupe-keys,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
@@ -57,6 +56,7 @@ describe('DocManager', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(err, doc) => {
|
||||
if (err) return done(err)
|
||||
doc.should.equal(this.doc)
|
||||
this.DocManager._getDoc
|
||||
.calledWith(this.project_id, this.doc_id, {
|
||||
@@ -98,6 +98,7 @@ describe('DocManager', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(err, doc) => {
|
||||
if (err) return done(err)
|
||||
doc.should.equal(this.doc)
|
||||
this.DocManager._getDoc
|
||||
.calledWith(this.project_id, this.doc_id, {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -228,6 +227,7 @@ describe('MongoManager', function () {
|
||||
this.doc_id,
|
||||
{ lines: this.lines },
|
||||
err => {
|
||||
assert.equal(err, this.stubbedErr)
|
||||
const args = this.db.docs.updateOne.args[0]
|
||||
assert.deepEqual(args[0], { _id: ObjectId(this.doc_id) })
|
||||
assert.equal(args[1].$set.lines, this.lines)
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"rules": {
|
||||
// TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671)
|
||||
// START of temporary overrides
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
"node/no-callback-literal": "off",
|
||||
"node/no-path-concat": "off",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -99,7 +98,7 @@ module.exports = DeleteQueueManager = {
|
||||
cutoffTime,
|
||||
function (err, project_id, flushTimestamp, queueLength) {
|
||||
if (err != null) {
|
||||
return callback(err)
|
||||
return callback(err, count)
|
||||
}
|
||||
if (project_id == null) {
|
||||
return callback(null, count)
|
||||
@@ -110,6 +109,11 @@ module.exports = DeleteQueueManager = {
|
||||
project_id,
|
||||
flushTimestamp,
|
||||
function (err, flushed) {
|
||||
if (err) {
|
||||
// Do not stop processing the queue in case the flush fails.
|
||||
// Slowing down the processing can fill up redis.
|
||||
metrics.inc('queued-delete-error')
|
||||
}
|
||||
if (flushed) {
|
||||
count++
|
||||
}
|
||||
@@ -137,7 +141,7 @@ module.exports = DeleteQueueManager = {
|
||||
min_delete_age: 3 * 60 * 1000,
|
||||
limit: 1000, // high value, to ensure we always flush enough projects
|
||||
},
|
||||
(err, flushed) =>
|
||||
(_err, flushed) =>
|
||||
setTimeout(doFlush, flushed > 10 ? SHORT_DELAY : LONG_DELAY)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -40,7 +39,7 @@ module.exports = DispatchManager = {
|
||||
client,
|
||||
_waitForUpdateThenDispatchWorker(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('worker.waiting')
|
||||
return worker.client.blpop(pendingListKey, 0, function (error, result) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -30,16 +29,7 @@ const MAX_UNFLUSHED_AGE = 300 * 1000 // 5 mins, document should be flushed to mo
|
||||
module.exports = DocumentManager = {
|
||||
getDoc(project_id, doc_id, _callback) {
|
||||
if (_callback == null) {
|
||||
_callback = function (
|
||||
error,
|
||||
lines,
|
||||
version,
|
||||
ranges,
|
||||
pathname,
|
||||
projectHistoryId,
|
||||
unflushedTime,
|
||||
alreadyLoaded
|
||||
) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('docManager.getDoc')
|
||||
const callback = function (...args) {
|
||||
@@ -147,15 +137,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
getDocAndRecentOps(project_id, doc_id, fromVersion, _callback) {
|
||||
if (_callback == null) {
|
||||
_callback = function (
|
||||
error,
|
||||
lines,
|
||||
version,
|
||||
ops,
|
||||
ranges,
|
||||
pathname,
|
||||
projectHistoryId
|
||||
) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('docManager.getDocAndRecentOps')
|
||||
const callback = function (...args) {
|
||||
@@ -207,7 +189,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
setDoc(project_id, doc_id, newLines, source, user_id, undoing, _callback) {
|
||||
if (_callback == null) {
|
||||
_callback = function (error) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('docManager.setDoc')
|
||||
const callback = function (...args) {
|
||||
@@ -325,7 +307,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
flushDocIfLoaded(project_id, doc_id, _callback) {
|
||||
if (_callback == null) {
|
||||
_callback = function (error) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('docManager.flushDocIfLoaded')
|
||||
const callback = function (...args) {
|
||||
@@ -421,7 +403,7 @@ module.exports = DocumentManager = {
|
||||
change_ids = []
|
||||
}
|
||||
if (_callback == null) {
|
||||
_callback = function (error) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('docManager.acceptChanges')
|
||||
const callback = function (...args) {
|
||||
@@ -471,7 +453,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
deleteComment(project_id, doc_id, comment_id, _callback) {
|
||||
if (_callback == null) {
|
||||
_callback = function (error) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('docManager.deleteComment')
|
||||
const callback = function (...args) {
|
||||
@@ -521,7 +503,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
renameDoc(project_id, doc_id, user_id, update, projectHistoryId, _callback) {
|
||||
if (_callback == null) {
|
||||
_callback = function (error) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('docManager.updateProject')
|
||||
const callback = function (...args) {
|
||||
@@ -541,7 +523,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
getDocAndFlushIfOld(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, doc) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return DocumentManager.getDoc(
|
||||
project_id,
|
||||
@@ -648,7 +630,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
getDocWithLock(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, lines, version) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const UpdateManager = require('./UpdateManager')
|
||||
return UpdateManager.lockUpdatesAndDo(
|
||||
@@ -661,15 +643,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
getDocAndRecentOpsWithLock(project_id, doc_id, fromVersion, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (
|
||||
error,
|
||||
lines,
|
||||
version,
|
||||
ops,
|
||||
ranges,
|
||||
pathname,
|
||||
projectHistoryId
|
||||
) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const UpdateManager = require('./UpdateManager')
|
||||
return UpdateManager.lockUpdatesAndDo(
|
||||
@@ -683,7 +657,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
getDocAndFlushIfOldWithLock(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, doc) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const UpdateManager = require('./UpdateManager')
|
||||
return UpdateManager.lockUpdatesAndDo(
|
||||
@@ -704,7 +678,7 @@ module.exports = DocumentManager = {
|
||||
callback
|
||||
) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const UpdateManager = require('./UpdateManager')
|
||||
return UpdateManager.lockUpdatesAndDo(
|
||||
@@ -721,7 +695,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
flushDocIfLoadedWithLock(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const UpdateManager = require('./UpdateManager')
|
||||
return UpdateManager.lockUpdatesAndDo(
|
||||
@@ -745,7 +719,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
acceptChangesWithLock(project_id, doc_id, change_ids, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const UpdateManager = require('./UpdateManager')
|
||||
return UpdateManager.lockUpdatesAndDo(
|
||||
@@ -759,7 +733,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
deleteCommentWithLock(project_id, doc_id, thread_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const UpdateManager = require('./UpdateManager')
|
||||
return UpdateManager.lockUpdatesAndDo(
|
||||
@@ -780,7 +754,7 @@ module.exports = DocumentManager = {
|
||||
callback
|
||||
) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const UpdateManager = require('./UpdateManager')
|
||||
return UpdateManager.lockUpdatesAndDo(
|
||||
@@ -796,7 +770,7 @@ module.exports = DocumentManager = {
|
||||
|
||||
resyncDocContentsWithLock(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const UpdateManager = require('./UpdateManager')
|
||||
return UpdateManager.lockUpdatesAndDo(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -92,7 +91,7 @@ module.exports = HistoryManager = {
|
||||
// flush changes and callback (for when we need to know the queue is flushed)
|
||||
flushProjectChanges(project_id, options, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (
|
||||
!__guard__(
|
||||
@@ -147,7 +146,7 @@ module.exports = HistoryManager = {
|
||||
ops = []
|
||||
}
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (ops.length === 0) {
|
||||
return callback()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -25,7 +24,7 @@ module.exports = HistoryRedisManager = {
|
||||
ops = []
|
||||
}
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (ops.length === 0) {
|
||||
return callback(new Error('cannot push no ops')) // This should never be called with no ops, but protect against a redis error if we sent an empty array to rpush
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -49,7 +48,7 @@ module.exports = LockManager = {
|
||||
|
||||
tryLock(doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (err, isFree) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const lockValue = LockManager.randomLock()
|
||||
const key = keys.blockingKey({ doc_id })
|
||||
@@ -94,7 +93,7 @@ module.exports = LockManager = {
|
||||
getLock(doc_id, callback) {
|
||||
let attempt
|
||||
if (callback == null) {
|
||||
callback = function (error, lockValue) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const startTime = Date.now()
|
||||
let testInterval = LockManager.LOCK_TEST_INTERVAL
|
||||
@@ -129,7 +128,7 @@ module.exports = LockManager = {
|
||||
|
||||
checkLock(doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (err, isFree) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const key = keys.blockingKey({ doc_id })
|
||||
return rclient.exists(key, function (err, exists) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -28,10 +27,8 @@ const metrics = require('./Metrics')
|
||||
module.exports = ProjectHistoryRedisManager = {
|
||||
queueOps(project_id, ...rest) {
|
||||
// Record metric for ops pushed onto queue
|
||||
const adjustedLength = Math.max(rest.length, 1)
|
||||
const ops = rest.slice(0, adjustedLength - 1)
|
||||
const val = rest[adjustedLength - 1]
|
||||
const callback = val != null ? val : function (error, projectUpdateCount) {}
|
||||
const callback = rest.pop()
|
||||
const ops = rest
|
||||
for (const op of Array.from(ops)) {
|
||||
metrics.summary('redis.projectHistoryOps', op.length, { status: 'push' })
|
||||
}
|
||||
@@ -96,7 +93,7 @@ module.exports = ProjectHistoryRedisManager = {
|
||||
callback
|
||||
) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
projectUpdate = {
|
||||
pathname: projectUpdate.pathname,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -29,7 +28,7 @@ module.exports = RangesManager = {
|
||||
updates = []
|
||||
}
|
||||
if (callback == null) {
|
||||
callback = function (error, new_entries, ranges_were_collapsed) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const { changes, comments } = _.cloneDeep(entries)
|
||||
const rangesTracker = new RangesTracker(changes, comments)
|
||||
@@ -95,7 +94,7 @@ module.exports = RangesManager = {
|
||||
|
||||
acceptChanges(change_ids, ranges, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, ranges) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const { changes, comments } = ranges
|
||||
logger.debug(`accepting ${change_ids.length} changes in ranges`)
|
||||
@@ -107,7 +106,7 @@ module.exports = RangesManager = {
|
||||
|
||||
deleteComment(comment_id, ranges, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, ranges) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const { changes, comments } = ranges
|
||||
logger.debug({ comment_id }, 'deleting comment in ranges')
|
||||
|
||||
@@ -56,7 +56,12 @@ module.exports = RateLimiter = class RateLimiter {
|
||||
|
||||
run(task, callback) {
|
||||
if (this.ActiveWorkerCount < this.CurrentWorkerLimit) {
|
||||
this._trackAndRun(task) // below the limit, just put the task in the background
|
||||
// below the limit, just put the task in the background
|
||||
this._trackAndRun(task, err => {
|
||||
if (err) {
|
||||
logger.error({ err }, 'error in background task')
|
||||
}
|
||||
})
|
||||
callback() // return immediately
|
||||
if (this.CurrentWorkerLimit > this.BaseWorkerCount) {
|
||||
return this._adjustLimitDown()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -160,7 +159,7 @@ module.exports = RedisManager = {
|
||||
|
||||
checkOrSetProjectState(project_id, newState, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, stateChanged) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const multi = rclient.multi()
|
||||
multi.getset(keys.projectState({ project_id }), newState)
|
||||
@@ -179,22 +178,14 @@ module.exports = RedisManager = {
|
||||
|
||||
clearProjectState(project_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return rclient.del(keys.projectState({ project_id }), callback)
|
||||
},
|
||||
|
||||
getDoc(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (
|
||||
error,
|
||||
lines,
|
||||
version,
|
||||
ranges,
|
||||
pathname,
|
||||
projectHistoryId,
|
||||
unflushedTime
|
||||
) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const timer = new metrics.Timer('redis.get-doc')
|
||||
const collectKeys = [
|
||||
@@ -292,7 +283,7 @@ module.exports = RedisManager = {
|
||||
|
||||
getDocVersion(doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, version, projectHistoryType) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return rclient.mget(
|
||||
keys.docVersion({ doc_id }),
|
||||
@@ -310,7 +301,7 @@ module.exports = RedisManager = {
|
||||
|
||||
getDocLines(doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, version) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return rclient.get(keys.docLines({ doc_id }), function (error, docLines) {
|
||||
if (error != null) {
|
||||
@@ -322,7 +313,7 @@ module.exports = RedisManager = {
|
||||
|
||||
getPreviousDocOps(doc_id, start, end, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, jsonOps) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const timer = new metrics.Timer('redis.get-prev-docops')
|
||||
return rclient.llen(keys.docOps({ doc_id }), function (error, length) {
|
||||
@@ -392,7 +383,7 @@ module.exports = RedisManager = {
|
||||
|
||||
getHistoryType(doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, projectHistoryType) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return rclient.get(
|
||||
keys.projectHistoryType({ doc_id }),
|
||||
@@ -407,7 +398,7 @@ module.exports = RedisManager = {
|
||||
|
||||
setHistoryType(doc_id, projectHistoryType, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return rclient.set(
|
||||
keys.projectHistoryType({ doc_id }),
|
||||
@@ -432,7 +423,7 @@ module.exports = RedisManager = {
|
||||
appliedOps = []
|
||||
}
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return RedisManager.getDocVersion(
|
||||
doc_id,
|
||||
@@ -572,8 +563,15 @@ module.exports = RedisManager = {
|
||||
return ProjectHistoryRedisManager.queueOps(
|
||||
project_id,
|
||||
...Array.from(jsonOps),
|
||||
(error, projectUpdateCount) =>
|
||||
(error, projectUpdateCount) => {
|
||||
if (error) {
|
||||
// The full project history can re-sync a project in case
|
||||
// updates went missing.
|
||||
// Just record the error here and acknowledge the write-op.
|
||||
metrics.inc('history-queue-error')
|
||||
}
|
||||
callback(null, docUpdateCount, projectUpdateCount)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
return callback(null, docUpdateCount)
|
||||
@@ -586,7 +584,7 @@ module.exports = RedisManager = {
|
||||
|
||||
renameDoc(project_id, doc_id, user_id, update, projectHistoryId, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return RedisManager.getDoc(
|
||||
project_id,
|
||||
@@ -632,14 +630,14 @@ module.exports = RedisManager = {
|
||||
|
||||
clearUnflushedTime(doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return rclient.del(keys.unflushedTime({ doc_id }), callback)
|
||||
},
|
||||
|
||||
getDocIdsInProject(project_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, doc_ids) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return rclient.smembers(keys.docsInProject({ project_id }), callback)
|
||||
},
|
||||
@@ -647,7 +645,7 @@ module.exports = RedisManager = {
|
||||
getDocTimestamps(doc_ids, callback) {
|
||||
// get lastupdatedat timestamps for an array of doc_ids
|
||||
if (callback == null) {
|
||||
callback = function (error, result) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return async.mapSeries(
|
||||
doc_ids,
|
||||
@@ -673,7 +671,7 @@ module.exports = RedisManager = {
|
||||
getNextProjectToFlushAndDelete(cutoffTime, callback) {
|
||||
// find the oldest queued flush that is before the cutoff time
|
||||
if (callback == null) {
|
||||
callback = function (error, key, timestamp) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return rclient.zrangebyscore(
|
||||
keys.flushAndDeleteQueue(),
|
||||
@@ -713,7 +711,7 @@ module.exports = RedisManager = {
|
||||
|
||||
_serializeRanges(ranges, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, serializedRanges) {}
|
||||
callback = function () {}
|
||||
}
|
||||
let jsonRanges = JSON.stringify(ranges)
|
||||
if (jsonRanges != null && jsonRanges.length > MAX_RANGES_SIZE) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -43,7 +42,7 @@ module.exports = ShareJsUpdateManager = {
|
||||
|
||||
applyUpdate(project_id, doc_id, update, lines, version, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, updatedDocLines) {}
|
||||
callback = function () {}
|
||||
}
|
||||
logger.debug({ project_id, doc_id, update }, 'applying sharejs updates')
|
||||
const jobs = []
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -34,7 +33,7 @@ const Profiler = require('./Profiler')
|
||||
module.exports = UpdateManager = {
|
||||
processOutstandingUpdates(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const timer = new Metrics.Timer('updateManager.processOutstandingUpdates')
|
||||
return UpdateManager.fetchAndApplyUpdates(
|
||||
@@ -52,7 +51,7 @@ module.exports = UpdateManager = {
|
||||
|
||||
processOutstandingUpdatesWithLock(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const profile = new Profiler('processOutstandingUpdatesWithLock', {
|
||||
project_id,
|
||||
@@ -97,7 +96,7 @@ module.exports = UpdateManager = {
|
||||
|
||||
continueProcessingUpdatesWithLock(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return RealTimeRedisManager.getUpdatesLength(doc_id, (error, length) => {
|
||||
if (error != null) {
|
||||
@@ -117,7 +116,7 @@ module.exports = UpdateManager = {
|
||||
|
||||
fetchAndApplyUpdates(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const profile = new Profiler('fetchAndApplyUpdates', { project_id, doc_id })
|
||||
return RealTimeRedisManager.getPendingUpdatesForDoc(
|
||||
@@ -150,7 +149,7 @@ module.exports = UpdateManager = {
|
||||
|
||||
applyUpdate(project_id, doc_id, update, _callback) {
|
||||
if (_callback == null) {
|
||||
_callback = function (error) {}
|
||||
_callback = function () {}
|
||||
}
|
||||
const callback = function (error) {
|
||||
if (error != null) {
|
||||
@@ -343,7 +342,19 @@ module.exports = UpdateManager = {
|
||||
// We held the lock for a while so updates might have queued up
|
||||
return UpdateManager.continueProcessingUpdatesWithLock(
|
||||
project_id,
|
||||
doc_id
|
||||
doc_id,
|
||||
err => {
|
||||
if (err) {
|
||||
// The processing may fail for invalid user updates.
|
||||
// This can be very noisy, put them on level DEBUG
|
||||
// and record a metric.
|
||||
Metrics.inc('background-processing-updates-error')
|
||||
logger.debug(
|
||||
{ err, project_id, doc_id },
|
||||
'error processing updates in background'
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -356,7 +367,7 @@ module.exports = UpdateManager = {
|
||||
|
||||
_handleErrorInsideLock(doc_id, lockValue, original_error, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return LockManager.releaseLock(doc_id, lockValue, lock_error =>
|
||||
callback(original_error)
|
||||
|
||||
@@ -40,8 +40,8 @@ const getKeys = function (pattern, callback) {
|
||||
}
|
||||
|
||||
const expireDocOps = callback =>
|
||||
// eslint-disable-next-line handle-callback-err
|
||||
getKeys(keys.docOps({ doc_id: '*' }), (error, keys) =>
|
||||
getKeys(keys.docOps({ doc_id: '*' }), (error, keys) => {
|
||||
if (error) return callback(error)
|
||||
async.mapSeries(
|
||||
keys,
|
||||
function (key, cb) {
|
||||
@@ -50,7 +50,7 @@ const expireDocOps = callback =>
|
||||
},
|
||||
callback
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
setTimeout(
|
||||
() =>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -92,6 +91,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.result)
|
||||
return done()
|
||||
}
|
||||
@@ -241,6 +241,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.result)
|
||||
return done()
|
||||
}
|
||||
@@ -254,11 +255,13 @@ describe('Applying updates to a doc', function () {
|
||||
0,
|
||||
-1,
|
||||
(error, updates) => {
|
||||
if (error) return done(error)
|
||||
JSON.parse(updates[0]).op.should.deep.equal(this.update.op)
|
||||
return rclient_history.sismember(
|
||||
HistoryKeys.docsWithHistoryOps({ project_id: this.project_id }),
|
||||
this.doc_id,
|
||||
(error, result) => {
|
||||
if (error) return done(error)
|
||||
result.should.equal(1)
|
||||
return done()
|
||||
}
|
||||
@@ -274,6 +277,7 @@ describe('Applying updates to a doc', function () {
|
||||
0,
|
||||
-1,
|
||||
(error, updates) => {
|
||||
if (error) return done(error)
|
||||
JSON.parse(updates[0]).op.should.deep.equal(this.update.op)
|
||||
return done()
|
||||
}
|
||||
@@ -323,6 +327,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.result)
|
||||
return done()
|
||||
}
|
||||
@@ -336,6 +341,7 @@ describe('Applying updates to a doc', function () {
|
||||
0,
|
||||
-1,
|
||||
(error, updates) => {
|
||||
if (error) return done(error)
|
||||
updates.length.should.equal(0)
|
||||
return done()
|
||||
}
|
||||
@@ -349,6 +355,7 @@ describe('Applying updates to a doc', function () {
|
||||
0,
|
||||
-1,
|
||||
(error, updates) => {
|
||||
if (error) return done(error)
|
||||
JSON.parse(updates[0]).op.should.deep.equal(this.update.op)
|
||||
return done()
|
||||
}
|
||||
@@ -425,6 +432,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.my_result)
|
||||
return done()
|
||||
}
|
||||
@@ -439,6 +447,7 @@ describe('Applying updates to a doc', function () {
|
||||
0,
|
||||
-1,
|
||||
(error, updates) => {
|
||||
if (error) return done(error)
|
||||
updates = Array.from(updates).map(u => JSON.parse(u))
|
||||
for (let i = 0; i < this.updates.length; i++) {
|
||||
const appliedUpdate = this.updates[i]
|
||||
@@ -449,6 +458,7 @@ describe('Applying updates to a doc', function () {
|
||||
HistoryKeys.docsWithHistoryOps({ project_id: this.project_id }),
|
||||
this.doc_id,
|
||||
(error, result) => {
|
||||
if (error) return done(error)
|
||||
result.should.equal(1)
|
||||
return done()
|
||||
}
|
||||
@@ -464,6 +474,7 @@ describe('Applying updates to a doc', function () {
|
||||
0,
|
||||
-1,
|
||||
(error, updates) => {
|
||||
if (error) return done(error)
|
||||
updates = Array.from(updates).map(u => JSON.parse(u))
|
||||
for (let i = 0; i < this.updates.length; i++) {
|
||||
const appliedUpdate = this.updates[i]
|
||||
@@ -538,6 +549,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.my_result)
|
||||
return done()
|
||||
}
|
||||
@@ -587,6 +599,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.lines)
|
||||
return done()
|
||||
}
|
||||
@@ -695,6 +708,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.result)
|
||||
return done()
|
||||
}
|
||||
@@ -775,6 +789,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
doc.lines.should.deep.equal(this.result)
|
||||
return done()
|
||||
}
|
||||
@@ -828,6 +843,7 @@ describe('Applying updates to a doc', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(404)
|
||||
return done()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
@@ -76,6 +73,7 @@ describe('Deleting a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.statusCode = res.statusCode
|
||||
return setTimeout(done, 200)
|
||||
}
|
||||
@@ -109,6 +107,7 @@ describe('Deleting a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
MockWebApi.getDocument
|
||||
.calledWith(this.project_id, this.doc_id)
|
||||
.should.equal(true)
|
||||
@@ -145,6 +144,7 @@ describe('Deleting a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.statusCode = res.statusCode
|
||||
return setTimeout(done, 200)
|
||||
}
|
||||
@@ -170,6 +170,7 @@ describe('Deleting a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
MockWebApi.getDocument
|
||||
.calledWith(this.project_id, this.doc_id)
|
||||
.should.equal(true)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -102,6 +101,7 @@ describe('Deleting a project', function () {
|
||||
return DocUpdaterClient.deleteProject(
|
||||
this.project_id,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.statusCode = res.statusCode
|
||||
return done()
|
||||
}
|
||||
@@ -141,6 +141,7 @@ describe('Deleting a project', function () {
|
||||
this.project_id,
|
||||
doc.id,
|
||||
(error, res, returnedDoc) => {
|
||||
if (error) return done(error)
|
||||
MockWebApi.getDocument
|
||||
.calledWith(this.project_id, doc.id)
|
||||
.should.equal(true)
|
||||
@@ -193,6 +194,7 @@ describe('Deleting a project', function () {
|
||||
return DocUpdaterClient.deleteProjectOnShutdown(
|
||||
this.project_id,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.statusCode = res.statusCode
|
||||
return done()
|
||||
}
|
||||
@@ -249,6 +251,7 @@ describe('Deleting a project', function () {
|
||||
return DocUpdaterClient.deleteProjectOnShutdown(
|
||||
this.project_id,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.statusCode = res.statusCode
|
||||
// after deleting the project and putting it in the queue, flush the queue
|
||||
return setTimeout(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -97,6 +96,7 @@ describe('Flushing a project', function () {
|
||||
return DocUpdaterClient.flushProject(
|
||||
this.project_id,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
this.statusCode = res.statusCode
|
||||
return done()
|
||||
}
|
||||
@@ -130,6 +130,7 @@ describe('Flushing a project', function () {
|
||||
this.project_id,
|
||||
doc.id,
|
||||
(error, res, returnedDoc) => {
|
||||
if (error) return done(error)
|
||||
returnedDoc.lines.should.deep.equal(doc.updatedLines)
|
||||
return callback()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -133,7 +132,7 @@ describe('Flushing a doc to Mongo', function () {
|
||||
callback
|
||||
) => {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
setTimeout(callback, t)
|
||||
return (t = 0)
|
||||
@@ -152,6 +151,7 @@ describe('Flushing a doc to Mongo', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(204)
|
||||
const delta = Date.now() - start
|
||||
expect(delta).to.be.below(20000)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -42,6 +41,7 @@ describe('Getting a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, returnedDoc) => {
|
||||
if (error) return done(error)
|
||||
this.returnedDoc = returnedDoc
|
||||
return done()
|
||||
}
|
||||
@@ -90,6 +90,7 @@ describe('Getting a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, returnedDoc) => {
|
||||
if (error) return done(error)
|
||||
this.returnedDoc = returnedDoc
|
||||
return done()
|
||||
}
|
||||
@@ -152,6 +153,7 @@ describe('Getting a document', function () {
|
||||
this.doc_id,
|
||||
190,
|
||||
(error, res, returnedDoc) => {
|
||||
if (error) return done(error)
|
||||
this.returnedDoc = returnedDoc
|
||||
return done()
|
||||
}
|
||||
@@ -174,6 +176,7 @@ describe('Getting a document', function () {
|
||||
this.doc_id,
|
||||
10,
|
||||
(error, res, returnedDoc) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.returnedDoc = returnedDoc
|
||||
return done()
|
||||
@@ -197,6 +200,7 @@ describe('Getting a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
this.statusCode = res.statusCode
|
||||
return done()
|
||||
}
|
||||
@@ -218,7 +222,7 @@ describe('Getting a document', function () {
|
||||
.stub(MockWebApi, 'getDocument')
|
||||
.callsFake((project_id, doc_id, callback) => {
|
||||
if (callback == null) {
|
||||
callback = function (error, doc) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return callback(new Error('oops'))
|
||||
})
|
||||
@@ -226,6 +230,7 @@ describe('Getting a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
this.statusCode = res.statusCode
|
||||
return done()
|
||||
}
|
||||
@@ -252,7 +257,7 @@ describe('Getting a document', function () {
|
||||
.stub(MockWebApi, 'getDocument')
|
||||
.callsFake((project_id, doc_id, callback) => {
|
||||
if (callback == null) {
|
||||
callback = function (error, doc) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return setTimeout(callback, 30000)
|
||||
})
|
||||
@@ -269,6 +274,7 @@ describe('Getting a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, doc) => {
|
||||
if (error) return done(error)
|
||||
res.statusCode.should.equal(500)
|
||||
const delta = Date.now() - start
|
||||
expect(delta).to.be.below(20000)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -48,6 +47,7 @@ describe('Getting documents for project', function () {
|
||||
this.project_id,
|
||||
this.projectStateHash,
|
||||
(error, res, returnedDocs) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.returnedDocs = returnedDocs
|
||||
return done()
|
||||
@@ -85,6 +85,7 @@ describe('Getting documents for project', function () {
|
||||
this.project_id,
|
||||
this.projectStateHash,
|
||||
(error, res0, returnedDocs0) => {
|
||||
if (error) return done(error)
|
||||
// set the hash
|
||||
this.res0 = res0
|
||||
this.returnedDocs0 = returnedDocs0
|
||||
@@ -92,6 +93,7 @@ describe('Getting documents for project', function () {
|
||||
this.project_id,
|
||||
this.projectStateHash,
|
||||
(error, res, returnedDocs) => {
|
||||
if (error) return done(error)
|
||||
// the hash should now match
|
||||
this.res = res
|
||||
this.returnedDocs = returnedDocs
|
||||
@@ -138,6 +140,7 @@ describe('Getting documents for project', function () {
|
||||
this.project_id,
|
||||
this.projectStateHash,
|
||||
(error, res0, returnedDocs0) => {
|
||||
if (error) return done(error)
|
||||
// set the hash
|
||||
this.res0 = res0
|
||||
this.returnedDocs0 = returnedDocs0
|
||||
@@ -145,11 +148,13 @@ describe('Getting documents for project', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, body) => {
|
||||
if (error) return done(error)
|
||||
// delete the doc
|
||||
return DocUpdaterClient.getProjectDocs(
|
||||
this.project_id,
|
||||
this.projectStateHash,
|
||||
(error, res1, returnedDocs) => {
|
||||
if (error) return done(error)
|
||||
// the hash would match, but the doc has been deleted
|
||||
this.res = res1
|
||||
this.returnedDocs = returnedDocs
|
||||
|
||||
@@ -67,6 +67,7 @@ describe('Peeking a document', function () {
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
(error, res, returnedDoc) => {
|
||||
if (error) return done(error)
|
||||
this.res = res
|
||||
this.returnedDoc = returnedDoc
|
||||
return done()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -335,6 +334,7 @@ describe('Ranges', function () {
|
||||
this.project_id,
|
||||
this.doc.id,
|
||||
(error, doc) => {
|
||||
if (error) return done(error)
|
||||
const { changes } = doc.ranges
|
||||
changes[0].op.should.deep.equal({ i: '123', p: 1 })
|
||||
changes[1].op.should.deep.equal({ i: '456', p: 5 })
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
@@ -21,7 +18,7 @@ module.exports = {
|
||||
callbacks: [],
|
||||
ensureRunning(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (this.running) {
|
||||
return callback()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -17,7 +16,7 @@ const app = express()
|
||||
module.exports = MockProjectHistoryApi = {
|
||||
flushProject(doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return callback()
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -17,7 +16,7 @@ const app = express()
|
||||
module.exports = MockTrackChangesApi = {
|
||||
flushDoc(doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return callback()
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -46,7 +45,7 @@ module.exports = MockWebApi = {
|
||||
callback
|
||||
) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const doc =
|
||||
this.docs[`${project_id}:${doc_id}`] ||
|
||||
@@ -62,7 +61,7 @@ module.exports = MockWebApi = {
|
||||
|
||||
getDocument(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, doc) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return callback(null, this.docs[`${project_id}:${doc_id}`])
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-undef,
|
||||
no-unused-vars,
|
||||
@@ -176,7 +175,7 @@ class StressTestClient {
|
||||
|
||||
runForNUpdates(n, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
this.updateCallback = callback
|
||||
this.updateCount = n
|
||||
@@ -185,7 +184,7 @@ class StressTestClient {
|
||||
|
||||
check(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return DocUpdaterClient.getDoc(
|
||||
this.project_id,
|
||||
@@ -275,7 +274,7 @@ class StressTestClient {
|
||||
|
||||
const checkDocument = function (project_id, doc_id, clients, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const jobs = clients.map(client => cb => client.check(cb))
|
||||
return async.parallel(jobs, callback)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -29,6 +28,7 @@ describe('DiffCodec', function () {
|
||||
this.before,
|
||||
this.after,
|
||||
(error, ops) => {
|
||||
if (error) return done(error)
|
||||
expect(ops).to.deep.equal([
|
||||
{
|
||||
i: 'beautiful ',
|
||||
@@ -47,6 +47,7 @@ describe('DiffCodec', function () {
|
||||
this.before,
|
||||
this.after,
|
||||
(error, ops) => {
|
||||
if (error) return done(error)
|
||||
expect(ops).to.deep.equal([
|
||||
{ i: 'tall ', p: 4 },
|
||||
{ i: 'red ', p: 29 },
|
||||
@@ -63,6 +64,7 @@ describe('DiffCodec', function () {
|
||||
this.before,
|
||||
this.after,
|
||||
(error, ops) => {
|
||||
if (error) return done(error)
|
||||
expect(ops).to.deep.equal([
|
||||
{
|
||||
d: 'beautiful ',
|
||||
@@ -81,6 +83,7 @@ describe('DiffCodec', function () {
|
||||
this.before,
|
||||
this.after,
|
||||
(error, ops) => {
|
||||
if (error) return done(error)
|
||||
expect(ops).to.deep.equal([
|
||||
{ d: 'tall ', p: 4 },
|
||||
{ d: 'red ', p: 24 },
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -168,7 +167,7 @@ describe('DispatchManager', function () {
|
||||
let callCount = 0
|
||||
this.worker._waitForUpdateThenDispatchWorker = callback => {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
callCount++
|
||||
if (callCount === 3) {
|
||||
|
||||
@@ -126,13 +126,17 @@ describe('HistoryManager', function () {
|
||||
|
||||
describe('flushProjectChanges', function () {
|
||||
describe('in the normal case', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
this.request.post = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, { statusCode: 204 })
|
||||
return this.HistoryManager.flushProjectChanges(this.project_id, {
|
||||
background: true,
|
||||
})
|
||||
return this.HistoryManager.flushProjectChanges(
|
||||
this.project_id,
|
||||
{
|
||||
background: true,
|
||||
},
|
||||
done
|
||||
)
|
||||
})
|
||||
|
||||
return it('should send a request to the project history api', function () {
|
||||
@@ -146,11 +150,15 @@ describe('HistoryManager', function () {
|
||||
})
|
||||
|
||||
return describe('with the skip_history_flush option', function () {
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
this.request.post = sinon.stub()
|
||||
return this.HistoryManager.flushProjectChanges(this.project_id, {
|
||||
skip_history_flush: true,
|
||||
})
|
||||
return this.HistoryManager.flushProjectChanges(
|
||||
this.project_id,
|
||||
{
|
||||
skip_history_flush: true,
|
||||
},
|
||||
done
|
||||
)
|
||||
})
|
||||
|
||||
return it('should not send a request to the project history api', function () {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -50,6 +49,7 @@ describe('LockManager - checking the lock', function () {
|
||||
it('should return true if the key does not exists', function (done) {
|
||||
existsStub.yields(null, '0')
|
||||
return LockManager.checkLock(doc_id, (err, free) => {
|
||||
if (err) return done(err)
|
||||
free.should.equal(true)
|
||||
return done()
|
||||
})
|
||||
@@ -58,6 +58,7 @@ describe('LockManager - checking the lock', function () {
|
||||
return it('should return false if the key does exists', function (done) {
|
||||
existsStub.yields(null, '1')
|
||||
return LockManager.checkLock(doc_id, (err, free) => {
|
||||
if (err) return done(err)
|
||||
free.should.equal(false)
|
||||
return done()
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -78,7 +77,7 @@ describe('LockManager - getting the lock', function () {
|
||||
this.LockManager.LOCK_TEST_INTERVAL = 5
|
||||
this.LockManager.tryLock = (doc_id, callback) => {
|
||||
if (callback == null) {
|
||||
callback = function (error, isFree) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (Date.now() - startTime < 20 || tries < 2) {
|
||||
tries = tries + 1
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -92,7 +91,7 @@ describe('ProjectManager - flushProject', function () {
|
||||
this.DocumentManager.flushDocIfLoadedWithLock = sinon.spy(
|
||||
(project_id, doc_id, callback) => {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (doc_id === 'doc-id-1') {
|
||||
return callback(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -417,6 +416,7 @@ describe('RangesManager', function () {
|
||||
this.change_ids,
|
||||
this.ranges,
|
||||
(err, ranges) => {
|
||||
if (err) return done(err)
|
||||
this.rangesResponse = ranges
|
||||
return done()
|
||||
}
|
||||
@@ -471,6 +471,7 @@ describe('RangesManager', function () {
|
||||
this.change_ids,
|
||||
this.ranges,
|
||||
(err, ranges) => {
|
||||
if (err) return done(err)
|
||||
this.rangesResponse = ranges
|
||||
return done()
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"rules": {
|
||||
// TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671)
|
||||
// START of temporary overrides
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
"node/no-callback-literal": "off",
|
||||
"node/no-path-concat": "off",
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"rules": {
|
||||
// TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671)
|
||||
// START of temporary overrides
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
"node/no-callback-literal": "off",
|
||||
"node/no-path-concat": "off",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -19,7 +18,7 @@ const metrics = require('@overleaf/metrics')
|
||||
module.exports = Notifications = {
|
||||
getUserNotifications(user_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (err, notifications) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const query = {
|
||||
user_id: ObjectId(user_id),
|
||||
@@ -30,7 +29,7 @@ module.exports = Notifications = {
|
||||
|
||||
_countExistingNotifications(user_id, notification, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (err, count) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const query = {
|
||||
user_id: ObjectId(user_id),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -15,7 +14,7 @@ const logger = require('logger-sharelatex')
|
||||
const metrics = require('@overleaf/metrics')
|
||||
|
||||
module.exports = {
|
||||
getUserNotifications(req, res) {
|
||||
getUserNotifications(req, res, next) {
|
||||
logger.log(
|
||||
{ user_id: req.params.user_id },
|
||||
'getting user unread notifications'
|
||||
@@ -23,7 +22,10 @@ module.exports = {
|
||||
metrics.inc('getUserNotifications')
|
||||
return Notifications.getUserNotifications(
|
||||
req.params.user_id,
|
||||
(err, notifications) => res.json(notifications)
|
||||
(err, notifications) => {
|
||||
if (err) return next(err)
|
||||
res.json(notifications)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
@@ -46,7 +48,7 @@ module.exports = {
|
||||
)
|
||||
},
|
||||
|
||||
removeNotificationId(req, res) {
|
||||
removeNotificationId(req, res, next) {
|
||||
logger.log(
|
||||
{
|
||||
user_id: req.params.user_id,
|
||||
@@ -58,11 +60,14 @@ module.exports = {
|
||||
return Notifications.removeNotificationId(
|
||||
req.params.user_id,
|
||||
req.params.notification_id,
|
||||
(err, notifications) => res.sendStatus(200)
|
||||
err => {
|
||||
if (err) return next(err)
|
||||
res.sendStatus(200)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
removeNotificationKey(req, res) {
|
||||
removeNotificationKey(req, res, next) {
|
||||
logger.log(
|
||||
{ user_id: req.params.user_id, notification_key: req.body.key },
|
||||
'mark key notification as read'
|
||||
@@ -71,18 +76,21 @@ module.exports = {
|
||||
return Notifications.removeNotificationKey(
|
||||
req.params.user_id,
|
||||
req.body.key,
|
||||
(err, notifications) => res.sendStatus(200)
|
||||
(err, notifications) => {
|
||||
if (err) return next(err)
|
||||
res.sendStatus(200)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
removeNotificationByKeyOnly(req, res) {
|
||||
removeNotificationByKeyOnly(req, res, next) {
|
||||
const notification_key = req.params.key
|
||||
logger.log({ notification_key }, 'mark notification as read by key only')
|
||||
metrics.inc('removeNotificationKey')
|
||||
return Notifications.removeNotificationByKeyOnly(
|
||||
notification_key,
|
||||
(err, notifications) => res.sendStatus(200)
|
||||
)
|
||||
return Notifications.removeNotificationByKeyOnly(notification_key, err => {
|
||||
if (err) return next(err)
|
||||
res.sendStatus(200)
|
||||
})
|
||||
},
|
||||
|
||||
countNotificationsByKeyOnly(req, res) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-dupe-keys,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
@@ -62,6 +61,7 @@ describe('Notifications Tests', function () {
|
||||
return this.notifications.getUserNotifications(
|
||||
user_id,
|
||||
(err, notifications) => {
|
||||
if (err) return done(err)
|
||||
notifications.should.equal(this.stubbedNotificationArray)
|
||||
assert.deepEqual(this.findStub.args[0][0], {
|
||||
user_id: ObjectId(user_id),
|
||||
@@ -228,6 +228,7 @@ describe('Notifications Tests', function () {
|
||||
user_id,
|
||||
notification_id,
|
||||
err => {
|
||||
if (err) return done(err)
|
||||
const searchOps = {
|
||||
user_id: ObjectId(user_id),
|
||||
_id: ObjectId(notification_id),
|
||||
@@ -251,6 +252,7 @@ describe('Notifications Tests', function () {
|
||||
user_id,
|
||||
notification_key,
|
||||
err => {
|
||||
if (err) return done(err)
|
||||
const searchOps = {
|
||||
user_id: ObjectId(user_id),
|
||||
key: notification_key,
|
||||
@@ -273,6 +275,7 @@ describe('Notifications Tests', function () {
|
||||
return this.notifications.removeNotificationByKeyOnly(
|
||||
notification_key,
|
||||
err => {
|
||||
if (err) return done(err)
|
||||
const searchOps = { key: notification_key }
|
||||
const updateOperation = { $unset: { templateKey: true } }
|
||||
assert.deepEqual(this.updateOneStub.args[0][0], searchOps)
|
||||
@@ -290,6 +293,7 @@ describe('Notifications Tests', function () {
|
||||
return this.notifications.deleteNotificationByKeyOnly(
|
||||
notification_key,
|
||||
err => {
|
||||
if (err) return done(err)
|
||||
const searchOps = { key: notification_key }
|
||||
assert.deepEqual(this.deleteOneStub.args[0][0], searchOps)
|
||||
return done()
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"rules": {
|
||||
// TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671)
|
||||
// START of temporary overrides
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
"node/no-callback-literal": "off",
|
||||
"node/no-path-concat": "off",
|
||||
|
||||
@@ -402,7 +402,10 @@ module.exports = Router = {
|
||||
'clientTracking.updatePosition',
|
||||
function (cursorData, callback) {
|
||||
if (!callback) {
|
||||
callback = function () {}
|
||||
callback = function () {
|
||||
// NOTE: The frontend does not pass any callback to socket.io.
|
||||
// Any error is already logged via Router._handleError.
|
||||
}
|
||||
}
|
||||
if (typeof callback !== 'function') {
|
||||
return Router._handleInvalidArguments(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -120,6 +119,7 @@ describe('applyOtUpdate', function () {
|
||||
|
||||
it('should push the doc into the pending updates list', function (done) {
|
||||
getPendingUpdatesList((error, ...rest) => {
|
||||
if (error) return done(error)
|
||||
const [doc_id] = Array.from(rest[0])
|
||||
doc_id.should.equal(`${this.project_id}:${this.doc_id}`)
|
||||
return done()
|
||||
@@ -135,6 +135,7 @@ describe('applyOtUpdate', function () {
|
||||
0,
|
||||
-1,
|
||||
(error, ...rest) => {
|
||||
if (error) return done(error)
|
||||
let [update] = Array.from(rest[0])
|
||||
update = JSON.parse(update)
|
||||
update.op.should.deep.equal(this.update.op)
|
||||
@@ -265,6 +266,7 @@ describe('applyOtUpdate', function () {
|
||||
doc_id: this.doc_id,
|
||||
}),
|
||||
(error, len) => {
|
||||
if (error) return done(error)
|
||||
len.should.equal(0)
|
||||
return done()
|
||||
}
|
||||
@@ -351,6 +353,7 @@ describe('applyOtUpdate', function () {
|
||||
doc_id: this.doc_id,
|
||||
}),
|
||||
(error, len) => {
|
||||
if (error) return done(error)
|
||||
len.should.equal(0)
|
||||
return done()
|
||||
}
|
||||
@@ -422,6 +425,7 @@ describe('applyOtUpdate', function () {
|
||||
|
||||
it('should push the doc into the pending updates list', function (done) {
|
||||
getPendingUpdatesList((error, ...rest) => {
|
||||
if (error) return done(error)
|
||||
const [doc_id] = Array.from(rest[0])
|
||||
doc_id.should.equal(`${this.project_id}:${this.doc_id}`)
|
||||
return done()
|
||||
@@ -437,6 +441,7 @@ describe('applyOtUpdate', function () {
|
||||
0,
|
||||
-1,
|
||||
(error, ...rest) => {
|
||||
if (error) return done(error)
|
||||
let [update] = Array.from(rest[0])
|
||||
update = JSON.parse(update)
|
||||
update.op.should.deep.equal(this.comment_update.op)
|
||||
@@ -551,6 +556,7 @@ describe('applyOtUpdate', function () {
|
||||
doc_id: this.doc_id,
|
||||
}),
|
||||
(error, len) => {
|
||||
if (error) return done(error)
|
||||
len.should.equal(0)
|
||||
return done()
|
||||
}
|
||||
@@ -637,6 +643,7 @@ describe('applyOtUpdate', function () {
|
||||
doc_id: this.doc_id,
|
||||
}),
|
||||
(error, len) => {
|
||||
if (error) return done(error)
|
||||
len.should.equal(0)
|
||||
return done()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -32,6 +31,7 @@ describe('clientTracking', function () {
|
||||
project: { name: 'Test Project' },
|
||||
},
|
||||
(error, { user_id, project_id }) => {
|
||||
if (error) return done(error)
|
||||
this.user_id = user_id
|
||||
this.project_id = project_id
|
||||
return cb()
|
||||
@@ -127,6 +127,7 @@ describe('clientTracking', function () {
|
||||
return this.clientB.emit(
|
||||
'clientTracking.getConnectedUsers',
|
||||
(error, users) => {
|
||||
if (error) return done(error)
|
||||
for (const user of Array.from(users)) {
|
||||
if (user.client_id === this.clientA.publicId) {
|
||||
expect(user.cursorData).to.deep.equal({
|
||||
@@ -155,6 +156,7 @@ describe('clientTracking', function () {
|
||||
publicAccess: 'readAndWrite',
|
||||
},
|
||||
(error, { user_id, project_id }) => {
|
||||
if (error) return done(error)
|
||||
this.user_id = user_id
|
||||
this.project_id = project_id
|
||||
return cb()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -107,6 +106,7 @@ describe('joinDoc', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true)
|
||||
return done()
|
||||
}
|
||||
@@ -194,6 +194,7 @@ describe('joinDoc', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true)
|
||||
return done()
|
||||
}
|
||||
@@ -281,6 +282,7 @@ describe('joinDoc', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true)
|
||||
return done()
|
||||
}
|
||||
@@ -367,6 +369,7 @@ describe('joinDoc', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes('invalid-doc-id')).to.equal(
|
||||
false
|
||||
)
|
||||
@@ -458,6 +461,7 @@ describe('joinDoc', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true)
|
||||
return done()
|
||||
}
|
||||
@@ -547,6 +551,7 @@ describe('joinDoc', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true)
|
||||
return done()
|
||||
}
|
||||
@@ -638,6 +643,7 @@ describe('joinDoc', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(true)
|
||||
return done()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -85,6 +84,7 @@ describe('joinProject', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.project_id)).to.equal(
|
||||
true
|
||||
)
|
||||
@@ -97,6 +97,7 @@ describe('joinProject', function () {
|
||||
return this.client.emit(
|
||||
'clientTracking.getConnectedUsers',
|
||||
(error, users) => {
|
||||
if (error) return done(error)
|
||||
let connected = false
|
||||
for (const user of Array.from(users)) {
|
||||
if (
|
||||
@@ -165,6 +166,7 @@ describe('joinProject', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.project_id)).to.equal(
|
||||
false
|
||||
)
|
||||
@@ -226,6 +228,7 @@ describe('joinProject', function () {
|
||||
RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.project_id)).to.equal(
|
||||
false
|
||||
)
|
||||
@@ -287,6 +290,7 @@ describe('joinProject', function () {
|
||||
RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.project_id)).to.equal(
|
||||
false
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
@@ -110,6 +109,7 @@ describe('leaveDoc', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(
|
||||
false
|
||||
)
|
||||
@@ -156,6 +156,7 @@ describe('leaveDoc', function () {
|
||||
return RealTimeClient.getConnectedClient(
|
||||
this.client.socket.sessionid,
|
||||
(error, client) => {
|
||||
if (error) return done(error)
|
||||
expect(Array.from(client.rooms).includes(this.doc_id)).to.equal(
|
||||
false
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-throw-literal,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -133,6 +132,7 @@ describe('leaveProject', function () {
|
||||
return this.clientB.emit(
|
||||
'clientTracking.getConnectedUsers',
|
||||
(error, users) => {
|
||||
if (error) return done(error)
|
||||
for (const user of Array.from(users)) {
|
||||
if (user.client_id === this.clientA.publicId) {
|
||||
throw 'Expected clientA to not be listed in connected users'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -38,6 +37,7 @@ describe('receiveUpdate', function () {
|
||||
project: { name: 'Test Project' },
|
||||
},
|
||||
(error, { user_id, project_id }) => {
|
||||
if (error) return done(error)
|
||||
this.user_id = user_id
|
||||
this.project_id = project_id
|
||||
return cb()
|
||||
@@ -104,6 +104,7 @@ describe('receiveUpdate', function () {
|
||||
error,
|
||||
{ user_id: user_id_second, project_id: project_id_second }
|
||||
) => {
|
||||
if (error) return done(error)
|
||||
this.user_id_second = user_id_second
|
||||
this.project_id_second = project_id_second
|
||||
return cb()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -45,6 +44,7 @@ describe('Session', function () {
|
||||
|
||||
return it('should appear in the list of connected clients', function (done) {
|
||||
return RealTimeClient.getConnectedClients((error, clients) => {
|
||||
if (error) return done(error)
|
||||
let included = false
|
||||
for (const client of Array.from(clients)) {
|
||||
if (client.client_id === this.client.socket.sessionid) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
@@ -21,7 +20,7 @@ module.exports = FixturesManager = {
|
||||
options = {}
|
||||
}
|
||||
if (callback == null) {
|
||||
callback = function (error, data) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (!options.user_id) {
|
||||
options.user_id = FixturesManager.getRandomId()
|
||||
@@ -74,7 +73,7 @@ module.exports = FixturesManager = {
|
||||
options = {}
|
||||
}
|
||||
if (callback == null) {
|
||||
callback = function (error, data) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (!options.doc_id) {
|
||||
options.doc_id = FixturesManager.getRandomId()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -24,7 +23,7 @@ module.exports = MockDocUpdaterServer = {
|
||||
|
||||
getDocument(project_id, doc_id, fromVersion, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, data) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return callback(null, MockDocUpdaterServer.docs[`${project_id}:${doc_id}`])
|
||||
},
|
||||
@@ -64,7 +63,7 @@ module.exports = MockDocUpdaterServer = {
|
||||
running: false,
|
||||
run(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (MockDocUpdaterServer.running) {
|
||||
return callback()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -26,7 +25,7 @@ module.exports = MockWebServer = {
|
||||
|
||||
joinProject(project_id, user_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, project, privilegeLevel) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return callback(
|
||||
null,
|
||||
@@ -70,7 +69,7 @@ module.exports = MockWebServer = {
|
||||
running: false,
|
||||
run(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
if (MockWebServer.running) {
|
||||
return callback()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
@@ -41,7 +40,7 @@ module.exports = Client = {
|
||||
|
||||
setSession(session, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
const sessionId = uid(24)
|
||||
session.cookie = {}
|
||||
@@ -58,7 +57,7 @@ module.exports = Client = {
|
||||
|
||||
unsetSession(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
callback = function () {}
|
||||
}
|
||||
Client.cookie = null
|
||||
return callback()
|
||||
@@ -77,7 +76,7 @@ module.exports = Client = {
|
||||
|
||||
getConnectedClients(callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, clients) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return request.get(
|
||||
{
|
||||
@@ -90,7 +89,7 @@ module.exports = Client = {
|
||||
|
||||
getConnectedClient(client_id, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, clients) {}
|
||||
callback = function () {}
|
||||
}
|
||||
return request.get(
|
||||
{
|
||||
@@ -116,12 +115,13 @@ module.exports = Client = {
|
||||
},
|
||||
|
||||
disconnectAllClients(callback) {
|
||||
return Client.getConnectedClients((error, clients) =>
|
||||
return Client.getConnectedClients((error, clients) => {
|
||||
if (error) return callback(error)
|
||||
async.each(
|
||||
clients,
|
||||
(clientView, cb) => Client.disconnectClient(clientView.client_id, cb),
|
||||
callback
|
||||
)
|
||||
)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user