mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #6116 from overleaf/bg-remove-large-broken-docs
[web] allow large broken docs to be deleted GitOrigin-RevId: 0322f55fcc5448ec1d6e6ee96056b80980bd3406
This commit is contained in:
parent
41c034b5fc
commit
e7f040ecf7
1 changed files with 23 additions and 1 deletions
|
@ -15,7 +15,12 @@ function parseArgs() {
|
||||||
boolean: ['commit'],
|
boolean: ['commit'],
|
||||||
})
|
})
|
||||||
const commit = args.commit
|
const commit = args.commit
|
||||||
return { commit, maxDocSize: 2 * 1024 * 1024 }
|
const deleteOversized = args['delete-oversized']
|
||||||
|
return {
|
||||||
|
commit,
|
||||||
|
deleteOversized,
|
||||||
|
maxDocSize: 2 * 1024 * 1024,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractObjectId(s) {
|
function extractObjectId(s) {
|
||||||
|
@ -74,12 +79,29 @@ async function processDoc(docId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// if the doc is too big we will need to convert it to a file, skip it for now
|
// if the doc is too big we will need to convert it to a file, skip it for now
|
||||||
|
// or delete the doc if the --delete-oversized option is used
|
||||||
const size = doc.lines.reduce((sum, line) => sum + line.length + 1, 0)
|
const size = doc.lines.reduce((sum, line) => sum + line.length + 1, 0)
|
||||||
if (size > opts.maxDocSize) {
|
if (size > opts.maxDocSize) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
{ docId, projectId, size },
|
{ docId, projectId, size },
|
||||||
'doc that exceeds max size, cannot restore'
|
'doc that exceeds max size, cannot restore'
|
||||||
)
|
)
|
||||||
|
if (opts.deleteOversized) {
|
||||||
|
logger.info(
|
||||||
|
{ docId, projectId, size, commit: opts.commit },
|
||||||
|
'forcing delete of large doc'
|
||||||
|
)
|
||||||
|
if (opts.commit) {
|
||||||
|
try {
|
||||||
|
await deleteDocFromRedis(projectId, docId)
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(
|
||||||
|
{ docId, projectId, deleteErr: err },
|
||||||
|
'error deleting doc from redis'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// now we have a doc content from redis, in a project where the doc has been deleted
|
// now we have a doc content from redis, in a project where the doc has been deleted
|
||||||
|
|
Loading…
Reference in a new issue