Merge pull request #8701 from overleaf/bg-simple-iterable-paths

simple iterable paths

GitOrigin-RevId: f6906016888ccfc95c88858bdac4d2633fc1c5f4
This commit is contained in:
Brian Gough
2022-07-04 11:12:01 +01:00
committed by Copybot
parent be71ea690d
commit 5a3318f5b3
7 changed files with 53 additions and 15 deletions

View File

@@ -22,6 +22,7 @@ const TpdsUpdateSender = require('../ThirdPartyDataStore/TpdsUpdateSender')
const FileWriter = require('../../infrastructure/FileWriter')
const EditorRealTimeController = require('../Editor/EditorRealTimeController')
const { promisifyAll } = require('../../util/promises')
const { iterablePaths } = require('./IterablePath')
const LOCK_NAMESPACE = 'sequentialProjectStructureUpdateLock'
const VALID_ROOT_DOC_EXTENSIONS = Settings.validRootDocExtensions
@@ -1608,16 +1609,16 @@ const ProjectEntityUpdateHandler = {
} else if (entityType.indexOf('folder') !== -1) {
changes = { oldDocs: [], oldFiles: [] }
const _recurseFolder = (folder, folderPath) => {
for (const doc of folder.docs) {
for (const doc of iterablePaths(folder, 'docs')) {
changes.oldDocs.push({ doc, path: Path.join(folderPath, doc.name) })
}
for (const file of folder.fileRefs) {
for (const file of iterablePaths(folder, 'fileRefs')) {
changes.oldFiles.push({
file,
path: Path.join(folderPath, file.name),
})
}
for (const childFolder of folder.folders) {
for (const childFolder of iterablePaths(folder, 'folders')) {
_recurseFolder(childFolder, Path.join(folderPath, childFolder.name))
}
}