Merge pull request #7123 from overleaf/jk-logging-catch-folder-error

[web] Add logging around crash site in `ProjectEntityHandler`

GitOrigin-RevId: 73ae00c10dba3783417d88785427c77c59faf57b
This commit is contained in:
ilkin-overleaf 2022-03-21 16:47:17 +02:00 committed by Copybot
parent da3b5b76c4
commit ebec861562

View file

@ -3,6 +3,7 @@ const DocstoreManager = require('../Docstore/DocstoreManager')
const Errors = require('../Errors/Errors')
const ProjectGetter = require('./ProjectGetter')
const { promisifyAll } = require('../../util/promises')
const OError = require('@overleaf/o-error')
const ProjectEntityHandler = {
getAllDocs(projectId, callback) {
@ -206,17 +207,23 @@ const ProjectEntityHandler = {
_getAllFoldersFromProject(project) {
const folders = []
function processFolder(basePath, folder) {
folders.push({ path: basePath, folder })
for (const childFolder of folder.folders || []) {
if (childFolder.name != null) {
processFolder(path.join(basePath, childFolder.name), childFolder)
try {
const processFolder = (basePath, folder) => {
folders.push({ path: basePath, folder })
if (folder.folders) {
for (const childFolder of folder.folders) {
if (childFolder.name != null) {
const childPath = path.join(basePath, childFolder.name)
processFolder(childPath, childFolder)
}
}
}
}
processFolder('/', project.rootFolder[0])
return folders
} catch (err) {
throw OError.tag(err, 'Error getting folders', { projectId: project._id })
}
processFolder('/', project.rootFolder[0])
return folders
},
}