mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
prettier auto-format
This commit is contained in:
parent
9712f518bd
commit
c854f1f570
20 changed files with 586 additions and 579 deletions
|
@ -40,8 +40,8 @@ module.exports = DocArchive = {
|
|||
new Errors.NotFoundError(`No docs for project ${project_id}`)
|
||||
)
|
||||
}
|
||||
docs = _.filter(docs, doc => doc.inS3 !== true)
|
||||
const jobs = _.map(docs, doc => cb =>
|
||||
docs = _.filter(docs, (doc) => doc.inS3 !== true)
|
||||
const jobs = _.map(docs, (doc) => (cb) =>
|
||||
DocArchive.archiveDoc(project_id, doc, cb)
|
||||
)
|
||||
return async.parallelLimit(jobs, 5, callback)
|
||||
|
@ -108,7 +108,10 @@ module.exports = DocArchive = {
|
|||
if (callback == null) {
|
||||
callback = function (err) {}
|
||||
}
|
||||
return MongoManager.getArchivedProjectDocs(project_id, function(err, docs) {
|
||||
return MongoManager.getArchivedProjectDocs(project_id, function (
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
if (err != null) {
|
||||
logger.err({ err, project_id }, 'error unarchiving all docs')
|
||||
return callback(err)
|
||||
|
@ -119,7 +122,7 @@ module.exports = DocArchive = {
|
|||
}
|
||||
const jobs = _.map(
|
||||
docs,
|
||||
doc =>
|
||||
(doc) =>
|
||||
function (cb) {
|
||||
if (doc.inS3 == null) {
|
||||
return cb()
|
||||
|
@ -184,7 +187,7 @@ module.exports = DocArchive = {
|
|||
} else if (docs == null) {
|
||||
return callback()
|
||||
}
|
||||
const jobs = _.map(docs, doc => cb =>
|
||||
const jobs = _.map(docs, (doc) => (cb) =>
|
||||
DocArchive.destroyDoc(project_id, doc._id, cb)
|
||||
)
|
||||
return async.parallelLimit(jobs, 5, callback)
|
||||
|
|
|
@ -37,7 +37,10 @@ module.exports = DocManager = {
|
|||
return callback('must include inS3 when getting doc')
|
||||
}
|
||||
|
||||
return MongoManager.findDoc(project_id, doc_id, filter, function(err, doc) {
|
||||
return MongoManager.findDoc(project_id, doc_id, filter, function (
|
||||
err,
|
||||
doc
|
||||
) {
|
||||
if (err != null) {
|
||||
return callback(err)
|
||||
} else if (doc == null) {
|
||||
|
|
|
@ -60,8 +60,8 @@ module.exports = {
|
|||
}
|
||||
})
|
||||
},
|
||||
cb => db.docs.remove({ _id: doc_id, project_id }, cb),
|
||||
cb => db.docOps.remove({ doc_id }, cb)
|
||||
(cb) => db.docs.remove({ _id: doc_id, project_id }, cb),
|
||||
(cb) => db.docOps.remove({ doc_id }, cb)
|
||||
]
|
||||
return async.series(jobs, callback)
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ module.exports = MongoManager = {
|
|||
_id: doc_id,
|
||||
rev
|
||||
}
|
||||
return db.docs.update(query, update, err => callback(err))
|
||||
return db.docs.update(query, update, (err) => callback(err))
|
||||
},
|
||||
|
||||
getDocVersion(doc_id, callback) {
|
||||
|
@ -170,6 +170,6 @@ module.exports = MongoManager = {
|
|||
'markDocAsArchived',
|
||||
'getDocVersion',
|
||||
'setDocVersion'
|
||||
].map(method =>
|
||||
].map((method) =>
|
||||
metrics.timeAsyncMethod(MongoManager, method, 'mongo.MongoManager', logger)
|
||||
)
|
||||
|
|
|
@ -45,9 +45,9 @@ describe('Archiving', function() {
|
|||
version: 4
|
||||
}
|
||||
]
|
||||
const jobs = Array.from(this.docs).map(doc =>
|
||||
(doc => {
|
||||
return callback => {
|
||||
const jobs = Array.from(this.docs).map((doc) =>
|
||||
((doc) => {
|
||||
return (callback) => {
|
||||
return DocstoreClient.createDoc(
|
||||
this.project_id,
|
||||
doc._id,
|
||||
|
@ -60,7 +60,7 @@ describe('Archiving', function() {
|
|||
})(doc)
|
||||
)
|
||||
|
||||
return async.series(jobs, error => {
|
||||
return async.series(jobs, (error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
@ -77,9 +77,9 @@ describe('Archiving', function() {
|
|||
})
|
||||
|
||||
it('should set inS3 and unset lines and ranges in each doc', function (done) {
|
||||
const jobs = Array.from(this.docs).map(doc =>
|
||||
(doc => {
|
||||
return callback => {
|
||||
const jobs = Array.from(this.docs).map((doc) =>
|
||||
((doc) => {
|
||||
return (callback) => {
|
||||
return db.docs.findOne({ _id: doc._id }, (error, doc) => {
|
||||
should.not.exist(doc.lines)
|
||||
should.not.exist(doc.ranges)
|
||||
|
@ -93,9 +93,9 @@ describe('Archiving', function() {
|
|||
})
|
||||
|
||||
it('should set the docs in s3 correctly', function (done) {
|
||||
const jobs = Array.from(this.docs).map(doc =>
|
||||
(doc => {
|
||||
return callback => {
|
||||
const jobs = Array.from(this.docs).map((doc) =>
|
||||
((doc) => {
|
||||
return (callback) => {
|
||||
return DocstoreClient.getS3Doc(
|
||||
this.project_id,
|
||||
doc._id,
|
||||
|
@ -136,7 +136,7 @@ describe('Archiving', function() {
|
|||
return it('should restore the docs to mongo', function (done) {
|
||||
const jobs = Array.from(this.docs).map((doc, i) =>
|
||||
((doc, i) => {
|
||||
return callback => {
|
||||
return (callback) => {
|
||||
return db.docs.findOne({ _id: doc._id }, (error, doc) => {
|
||||
doc.lines.should.deep.equal(this.docs[i].lines)
|
||||
doc.ranges.should.deep.equal(this.docs[i].ranges)
|
||||
|
@ -166,14 +166,14 @@ describe('Archiving', function() {
|
|||
this.doc.lines,
|
||||
this.doc.version,
|
||||
this.doc.ranges,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
return DocstoreClient.deleteDoc(
|
||||
this.project_id,
|
||||
this.doc._id,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ describe('Archiving', function() {
|
|||
this.doc.lines,
|
||||
this.doc.version,
|
||||
this.doc.ranges,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ describe('Archiving', function() {
|
|||
this.doc.lines,
|
||||
this.doc.version,
|
||||
this.doc.ranges,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
@ -873,7 +873,7 @@ describe('Archiving', function() {
|
|||
this.doc.lines,
|
||||
this.doc.version,
|
||||
this.doc.ranges,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
@ -964,7 +964,7 @@ describe('Archiving', function() {
|
|||
this.doc.lines,
|
||||
this.doc.version,
|
||||
this.doc.ranges,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
@ -1070,7 +1070,7 @@ describe('Archiving', function() {
|
|||
rev: this.doc.version,
|
||||
inS3: true
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ describe('Deleting a doc', function() {
|
|||
this.lines,
|
||||
this.version,
|
||||
this.ranges,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
|
|
@ -50,9 +50,9 @@ describe('Getting all docs', function() {
|
|||
rev: 8
|
||||
}
|
||||
const version = 42
|
||||
const jobs = Array.from(this.docs).map(doc =>
|
||||
(doc => {
|
||||
return callback => {
|
||||
const jobs = Array.from(this.docs).map((doc) =>
|
||||
((doc) => {
|
||||
return (callback) => {
|
||||
return DocstoreClient.createDoc(
|
||||
this.project_id,
|
||||
doc._id,
|
||||
|
@ -64,14 +64,14 @@ describe('Getting all docs', function() {
|
|||
}
|
||||
})(doc)
|
||||
)
|
||||
jobs.push(cb => {
|
||||
jobs.push((cb) => {
|
||||
return DocstoreClient.createDoc(
|
||||
this.project_id,
|
||||
this.deleted_doc._id,
|
||||
this.deleted_doc.lines,
|
||||
version,
|
||||
this.deleted_doc.ranges,
|
||||
err => {
|
||||
(err) => {
|
||||
return DocstoreClient.deleteDoc(
|
||||
this.project_id,
|
||||
this.deleted_doc._id,
|
||||
|
@ -80,7 +80,7 @@ describe('Getting all docs', function() {
|
|||
}
|
||||
)
|
||||
})
|
||||
jobs.unshift(cb => DocstoreApp.ensureRunning(cb))
|
||||
jobs.unshift((cb) => DocstoreApp.ensureRunning(cb))
|
||||
return async.series(jobs, done)
|
||||
})
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ describe('Getting a doc', function() {
|
|||
this.lines,
|
||||
this.version,
|
||||
this.ranges,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ describe('Getting a doc', function() {
|
|||
this.lines,
|
||||
this.version,
|
||||
this.ranges,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ describe('Applying updates to a doc', function() {
|
|||
this.originalLines,
|
||||
this.version,
|
||||
this.originalRanges,
|
||||
error => {
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
|
|
@ -30,7 +30,10 @@ module.exports = {
|
|||
} else {
|
||||
this.initing = true
|
||||
this.callbacks.push(callback)
|
||||
return app.listen(settings.internal.docstore.port, 'localhost', error => {
|
||||
return app.listen(
|
||||
settings.internal.docstore.port,
|
||||
'localhost',
|
||||
(error) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
}
|
||||
|
@ -42,7 +45,8 @@ module.exports = {
|
|||
}
|
||||
return result
|
||||
})()
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ describe('DocArchiveManager', function() {
|
|||
return this.DocArchiveManager.archiveDoc(
|
||||
this.project_id,
|
||||
this.mongoDocs[0],
|
||||
err => {
|
||||
(err) => {
|
||||
const opts = this.request.put.args[0][0]
|
||||
assert.deepEqual(opts.aws, {
|
||||
key: this.settings.docstore.s3.key,
|
||||
|
@ -172,17 +172,14 @@ describe('DocArchiveManager', function() {
|
|||
ranges: this.mongoDocs[0].ranges,
|
||||
schema_v: 1
|
||||
})
|
||||
this.md5 = crypto
|
||||
.createHash('md5')
|
||||
.update(data)
|
||||
.digest('hex')
|
||||
this.md5 = crypto.createHash('md5').update(data).digest('hex')
|
||||
this.request.put = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, { statusCode: 200, headers: { etag: this.md5 } })
|
||||
return this.DocArchiveManager.archiveDoc(
|
||||
this.project_id,
|
||||
this.mongoDocs[0],
|
||||
err => {
|
||||
(err) => {
|
||||
should.not.exist(err)
|
||||
return done()
|
||||
}
|
||||
|
@ -197,7 +194,7 @@ describe('DocArchiveManager', function() {
|
|||
return this.DocArchiveManager.archiveDoc(
|
||||
this.project_id,
|
||||
this.mongoDocs[0],
|
||||
err => {
|
||||
(err) => {
|
||||
should.exist(err)
|
||||
return done()
|
||||
}
|
||||
|
@ -216,7 +213,7 @@ describe('DocArchiveManager', function() {
|
|||
return this.DocArchiveManager.unarchiveDoc(
|
||||
this.project_id,
|
||||
this.mongoDocs[0]._id,
|
||||
err => {
|
||||
(err) => {
|
||||
const opts = this.request.get.args[0][0]
|
||||
assert.deepEqual(opts.aws, {
|
||||
key: this.settings.docstore.s3.key,
|
||||
|
@ -238,7 +235,7 @@ describe('DocArchiveManager', function() {
|
|||
return this.DocArchiveManager.unarchiveDoc(
|
||||
this.project_id,
|
||||
this.mongoDocs[0],
|
||||
err => {
|
||||
(err) => {
|
||||
should.exist(err)
|
||||
return done()
|
||||
}
|
||||
|
@ -253,7 +250,7 @@ describe('DocArchiveManager', function() {
|
|||
return this.DocArchiveManager.unarchiveDoc(
|
||||
this.project_id,
|
||||
this.mongoDocs[0],
|
||||
err => {
|
||||
(err) => {
|
||||
should.exist(err)
|
||||
this.request.del.called.should.equal(false)
|
||||
return done()
|
||||
|
@ -269,7 +266,7 @@ describe('DocArchiveManager', function() {
|
|||
.callsArgWith(3, null, this.mongoDocs)
|
||||
this.DocArchiveManager.archiveDoc = sinon.stub().callsArgWith(2, null)
|
||||
|
||||
return this.DocArchiveManager.archiveAllDocs(this.project_id, err => {
|
||||
return this.DocArchiveManager.archiveAllDocs(this.project_id, (err) => {
|
||||
this.DocArchiveManager.archiveDoc
|
||||
.calledWith(this.project_id, this.mongoDocs[0])
|
||||
.should.equal(true)
|
||||
|
@ -297,7 +294,7 @@ describe('DocArchiveManager', function() {
|
|||
.stub()
|
||||
.callsArgWith(3, null, null)
|
||||
|
||||
return this.DocArchiveManager.archiveAllDocs(this.project_id, err => {
|
||||
return this.DocArchiveManager.archiveAllDocs(this.project_id, (err) => {
|
||||
should.exist(err)
|
||||
return done()
|
||||
})
|
||||
|
@ -308,7 +305,7 @@ describe('DocArchiveManager', function() {
|
|||
.stub()
|
||||
.callsArgWith(3, this.error, null)
|
||||
|
||||
return this.DocArchiveManager.archiveAllDocs(this.project_id, err => {
|
||||
return this.DocArchiveManager.archiveAllDocs(this.project_id, (err) => {
|
||||
err.should.equal(this.error)
|
||||
return done()
|
||||
})
|
||||
|
@ -331,7 +328,7 @@ describe('DocArchiveManager', function() {
|
|||
})
|
||||
|
||||
return it('should not throw and error', function (done) {
|
||||
return this.DocArchiveManager.archiveAllDocs(this.project_id, err => {
|
||||
return this.DocArchiveManager.archiveAllDocs(this.project_id, (err) => {
|
||||
should.not.exist(err)
|
||||
return done()
|
||||
})
|
||||
|
@ -345,7 +342,7 @@ describe('DocArchiveManager', function() {
|
|||
.stub()
|
||||
.callsArgWith(1, null, this.archivedDocs)
|
||||
this.DocArchiveManager.unarchiveDoc = sinon.stub().callsArgWith(2, null)
|
||||
return this.DocArchiveManager.unArchiveAllDocs(this.project_id, err => {
|
||||
return this.DocArchiveManager.unArchiveAllDocs(this.project_id, (err) => {
|
||||
for (const doc of Array.from(this.archivedDocs)) {
|
||||
this.DocArchiveManager.unarchiveDoc
|
||||
.calledWith(this.project_id, doc._id)
|
||||
|
@ -360,7 +357,7 @@ describe('DocArchiveManager', function() {
|
|||
this.MongoManager.getArchivedProjectDocs = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, null)
|
||||
return this.DocArchiveManager.unArchiveAllDocs(this.project_id, err => {
|
||||
return this.DocArchiveManager.unArchiveAllDocs(this.project_id, (err) => {
|
||||
should.exist(err)
|
||||
return done()
|
||||
})
|
||||
|
@ -370,7 +367,7 @@ describe('DocArchiveManager', function() {
|
|||
this.MongoManager.getArchivedProjectDocs = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, this.error, null)
|
||||
return this.DocArchiveManager.unArchiveAllDocs(this.project_id, err => {
|
||||
return this.DocArchiveManager.unArchiveAllDocs(this.project_id, (err) => {
|
||||
err.should.equal(this.error)
|
||||
return done()
|
||||
})
|
||||
|
@ -387,7 +384,7 @@ describe('DocArchiveManager', function() {
|
|||
.callsArgWith(3, null, this.mixedDocs)
|
||||
this.MongoManager.findDoc = sinon.stub().callsArgWith(3, null, null)
|
||||
this.MongoManager.destroyDoc = sinon.stub().yields()
|
||||
return Array.from(this.mixedDocs).map(doc =>
|
||||
return Array.from(this.mixedDocs).map((doc) =>
|
||||
this.MongoManager.findDoc
|
||||
.withArgs(this.project_id, doc._id)
|
||||
.callsArgWith(3, null, doc)
|
||||
|
@ -396,7 +393,7 @@ describe('DocArchiveManager', function() {
|
|||
|
||||
it('should destroy all the docs', function (done) {
|
||||
this.DocArchiveManager.destroyDoc = sinon.stub().callsArgWith(2, null)
|
||||
return this.DocArchiveManager.destroyAllDocs(this.project_id, err => {
|
||||
return this.DocArchiveManager.destroyAllDocs(this.project_id, (err) => {
|
||||
for (const doc of Array.from(this.mixedDocs)) {
|
||||
this.DocArchiveManager.destroyDoc
|
||||
.calledWith(this.project_id, doc._id)
|
||||
|
@ -408,7 +405,7 @@ describe('DocArchiveManager', function() {
|
|||
})
|
||||
|
||||
it('should only the s3 docs from s3', function (done) {
|
||||
const docOpts = doc => {
|
||||
const docOpts = (doc) => {
|
||||
return JSON.parse(
|
||||
JSON.stringify({
|
||||
aws: {
|
||||
|
@ -423,7 +420,7 @@ describe('DocArchiveManager', function() {
|
|||
)
|
||||
}
|
||||
|
||||
return this.DocArchiveManager.destroyAllDocs(this.project_id, err => {
|
||||
return this.DocArchiveManager.destroyAllDocs(this.project_id, (err) => {
|
||||
let doc
|
||||
expect(err).not.to.exist
|
||||
|
||||
|
@ -439,7 +436,7 @@ describe('DocArchiveManager', function() {
|
|||
})
|
||||
|
||||
return it('should remove the docs from mongo', function (done) {
|
||||
this.DocArchiveManager.destroyAllDocs(this.project_id, err => {
|
||||
this.DocArchiveManager.destroyAllDocs(this.project_id, (err) => {
|
||||
return expect(err).not.to.exist
|
||||
})
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ describe('DocManager', function() {
|
|||
this.project_id,
|
||||
this.doc_id,
|
||||
{ inS3: false },
|
||||
err => {
|
||||
(err) => {
|
||||
expect(err).to.exist
|
||||
return done()
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ describe('DocManager', function() {
|
|||
this.project_id,
|
||||
this.doc_id,
|
||||
undefined,
|
||||
err => {
|
||||
(err) => {
|
||||
this.MongoManager.findDoc.called.should.equal(false)
|
||||
expect(err).to.exist
|
||||
return done()
|
||||
|
@ -224,7 +224,7 @@ describe('DocManager', function() {
|
|||
this.project_id,
|
||||
this.doc_id,
|
||||
{ inS3: true },
|
||||
err => {
|
||||
(err) => {
|
||||
expect(err).to.not.exist
|
||||
return done()
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ describe('MongoManager', function() {
|
|||
this.project_id,
|
||||
this.doc_id,
|
||||
{ lines: this.lines },
|
||||
err => {
|
||||
(err) => {
|
||||
const args = this.db.docs.update.args[0]
|
||||
assert.deepEqual(args[0], { _id: ObjectId(this.doc_id) })
|
||||
assert.equal(args[1].$set.lines, this.lines)
|
||||
|
@ -164,7 +164,7 @@ describe('MongoManager', function() {
|
|||
this.project_id,
|
||||
this.doc_id,
|
||||
{ lines: this.lines },
|
||||
err => {
|
||||
(err) => {
|
||||
err.should.equal(this.stubbedErr)
|
||||
return done()
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ describe('MongoManager', function() {
|
|||
return this.MongoManager.markDocAsDeleted(
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
err => {
|
||||
(err) => {
|
||||
const args = this.db.docs.update.args[0]
|
||||
assert.deepEqual(args[0], {
|
||||
_id: ObjectId(this.doc_id),
|
||||
|
@ -198,7 +198,7 @@ describe('MongoManager', function() {
|
|||
return this.MongoManager.markDocAsDeleted(
|
||||
this.project_id,
|
||||
this.doc_id,
|
||||
err => {
|
||||
(err) => {
|
||||
err.should.equal(this.stubbedErr)
|
||||
return done()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue