Skip to content

Commit ec5fe52

Browse files
committed
Shuffle directories when cleaning distributions
1 parent 1843467 commit ec5fe52

File tree

1 file changed

+9
-0
lines changed
  • extensions/ql-vscode/src/codeql-cli/distribution

1 file changed

+9
-0
lines changed

extensions/ql-vscode/src/codeql-cli/distribution/cleaner.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ export class ExtensionManagedDistributionCleaner {
8383
return;
8484
}
8585

86+
// Shuffle the array so that multiple VS Code processes don't all try to clean up the same directory at the same time
87+
for (let i = cleanableDirectories.length - 1; i > 0; i--) {
88+
const j = Math.floor(Math.random() * (i + 1));
89+
[cleanableDirectories[i], cleanableDirectories[j]] = [
90+
cleanableDirectories[j],
91+
cleanableDirectories[i],
92+
];
93+
}
94+
8695
void this.logger.log(
8796
`Cleaning up ${cleanableDirectories.length} old versions of the CLI.`,
8897
);

0 commit comments

Comments
 (0)