From f0efa90b2527f69db15ab871ea33c0ea033e4e3f Mon Sep 17 00:00:00 2001 From: Eric Mc Sween Date: Thu, 19 May 2022 07:29:29 -0400 Subject: [PATCH] Merge pull request #8033 from overleaf/em-find-files-without-ids Script to find files and docs without ids in projects GitOrigin-RevId: 5c29d92748a01a1e48288479b25560127aafd397 --- services/web/scripts/find_malformed_filetrees.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/services/web/scripts/find_malformed_filetrees.js b/services/web/scripts/find_malformed_filetrees.js index 203d79fc47..083685984f 100644 --- a/services/web/scripts/find_malformed_filetrees.js +++ b/services/web/scripts/find_malformed_filetrees.js @@ -35,6 +35,10 @@ function processProject(project) { function findBadPaths(folder) { const result = [] + if (!folder._id) { + result.push('_id') + } + if (typeof folder.name !== 'string' || !folder.name) { result.push('name') } @@ -62,9 +66,13 @@ function findBadPaths(folder) { result.push(`docs.${i}`) continue } + if (!doc._id) { + result.push(`docs.${i}._id`) + // no need to check further: this doc can be deleted + continue + } if (typeof doc.name !== 'string' || !doc.name) { result.push(`docs.${i}.name`) - continue } } } else { @@ -79,9 +87,13 @@ function findBadPaths(folder) { result.push(`fileRefs.${i}`) continue } + if (!file._id) { + result.push(`fileRefs.${i}._id`) + // no need to check further: this file can be deleted + continue + } if (typeof file.name !== 'string' || !file.name) { result.push(`fileRefs.${i}.name`) - continue } } } else {