Skip to content

Commit

Permalink
Merge pull request #4416 from 3drepo/ISSUE_4415
Browse files Browse the repository at this point in the history
ISSUE #4415 write the zombies in chunks
  • Loading branch information
carmenfan authored Aug 24, 2023
2 parents adac26f + 3bf1e61 commit f5e6b89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions backend/src/scripts/utility/fileshare/identifyZombieFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ const run = async (outFile = DEFAULT_OUT_FILE, removeFiles = false, maxParallelR
if (zombies.length) {
logger.logInfo(`Writing all links to ${outFile}...`);

writeFileSync(outFile, zombies.join('\n'));
const chunks = splitArrayIntoChunks(zombies, maxParallelRefs);
for (let i = 0; i < chunks.length; ++i) {
writeFileSync(outFile, `${chunks[i].join('\n')}\n`, { flag: i === 0 ? 'w' : 'a' });
logger.logInfo(`[${i}/${chunks.length}] ${chunks[i].length} file paths written...`);
}
if (removeFiles) {
const chunks = splitArrayIntoChunks(zombies, maxParallelRefs);
logger.logInfo(`Deleting files (${chunks.length} batches)`);
for (let i = 0; i < chunks.length; ++i) {
const group = chunks[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const runTest = (data) => {
});

test('Should remove zombie files if flag is set', async () => {
await IdentifyZombieFiles.run(undefined, true);
await IdentifyZombieFiles.run(undefined, true, 1);

checkFileExists(data.referencedLinks, true);
checkFileExists(data.toyLinks, true);
Expand Down

0 comments on commit f5e6b89

Please sign in to comment.