mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #5997 from overleaf/em-track-changes-docstore-404
Skip inexistent docs when building ShareLaTeX history GitOrigin-RevId: 5b7c5b77623d77c7d20f852050249211de0c8cb3
This commit is contained in:
parent
be17e022a6
commit
98a4742c0a
3 changed files with 28 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
const request = require('request')
|
const request = require('request')
|
||||||
const logger = require('logger-sharelatex')
|
const logger = require('logger-sharelatex')
|
||||||
const Settings = require('@overleaf/settings')
|
const Settings = require('@overleaf/settings')
|
||||||
|
const Errors = require('./Errors')
|
||||||
|
|
||||||
function peekDocument(projectId, docId, callback) {
|
function peekDocument(projectId, docId, callback) {
|
||||||
const url = `${Settings.apis.docstore.url}/project/${projectId}/doc/${docId}/peek`
|
const url = `${Settings.apis.docstore.url}/project/${projectId}/doc/${docId}/peek`
|
||||||
|
@ -15,8 +16,7 @@ function peekDocument(projectId, docId, callback) {
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
try {
|
try {
|
||||||
body = JSON.parse(body)
|
body = JSON.parse(body)
|
||||||
} catch (error1) {
|
} catch (error) {
|
||||||
error = error1
|
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
logger.log(
|
logger.log(
|
||||||
|
@ -24,6 +24,10 @@ function peekDocument(projectId, docId, callback) {
|
||||||
'got doc from docstore'
|
'got doc from docstore'
|
||||||
)
|
)
|
||||||
return callback(null, body.lines.join('\n'), body.version)
|
return callback(null, body.lines.join('\n'), body.version)
|
||||||
|
} else if (res.statusCode === 404) {
|
||||||
|
return callback(
|
||||||
|
new Errors.NotFoundError('doc not found', { projectId, docId })
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
return callback(
|
return callback(
|
||||||
new Error(
|
new Error(
|
||||||
|
|
5
services/track-changes/app/js/Errors.js
Normal file
5
services/track-changes/app/js/Errors.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
const OError = require('@overleaf/o-error')
|
||||||
|
|
||||||
|
class NotFoundError extends OError {}
|
||||||
|
|
||||||
|
module.exports = { NotFoundError }
|
|
@ -3,6 +3,7 @@ const UpdatesManager = require('./UpdatesManager')
|
||||||
const DiffGenerator = require('./DiffGenerator')
|
const DiffGenerator = require('./DiffGenerator')
|
||||||
const DocumentUpdaterManager = require('./DocumentUpdaterManager')
|
const DocumentUpdaterManager = require('./DocumentUpdaterManager')
|
||||||
const DocstoreManager = require('./DocstoreManager')
|
const DocstoreManager = require('./DocstoreManager')
|
||||||
|
const Errors = require('./Errors')
|
||||||
const PackManager = require('./PackManager')
|
const PackManager = require('./PackManager')
|
||||||
const yazl = require('yazl')
|
const yazl = require('yazl')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
@ -47,11 +48,22 @@ async function rewindDoc(projectId, docId, zipfile) {
|
||||||
|
|
||||||
const lastUpdateVersion = lastUpdate.v
|
const lastUpdateVersion = lastUpdate.v
|
||||||
|
|
||||||
const [latestContent, version] = await getLatestContent(
|
let latestContent
|
||||||
|
let version
|
||||||
|
try {
|
||||||
|
;[latestContent, version] = await getLatestContent(
|
||||||
projectId,
|
projectId,
|
||||||
docId,
|
docId,
|
||||||
lastUpdateVersion
|
lastUpdateVersion
|
||||||
)
|
)
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof Errors.NotFoundError) {
|
||||||
|
// Doc not found in docstore. We can't build its history
|
||||||
|
return null
|
||||||
|
} else {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const id = docId.toString()
|
const id = docId.toString()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue