From c5e6309fc16866b85c803f132c7f8d968d97645a Mon Sep 17 00:00:00 2001 From: Snjezana Peco Date: Thu, 2 Nov 2023 22:04:26 +0100 Subject: [PATCH] Delete client log files when deleting workspace Signed-off-by: Snjezana Peco --- src/extension.ts | 5 ++++- src/utils.ts | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index a113e1222d..938cf62703 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -29,7 +29,7 @@ import { snippetCompletionProvider } from './snippetCompletionProvider'; import { JavaClassEditorProvider } from './javaClassEditor'; import { StandardLanguageClient } from './standardLanguageClient'; import { SyntaxLanguageClient } from './syntaxLanguageClient'; -import { convertToGlob, deleteDirectory, ensureExists, getBuildFilePatterns, getExclusionBlob, getInclusionPatternsFromNegatedExclusion, getJavaConfig, getJavaConfiguration, hasBuildToolConflicts } from './utils'; +import { convertToGlob, deleteClientLog, deleteDirectory, ensureExists, getBuildFilePatterns, getExclusionBlob, getInclusionPatternsFromNegatedExclusion, getJavaConfig, getJavaConfiguration, hasBuildToolConflicts } from './utils'; import glob = require('glob'); import { Telemetry } from './telemetry'; import { getMessage } from './errorUtils'; @@ -321,6 +321,7 @@ export async function activate(context: ExtensionContext): Promise try { cleanupLombokCache(context); deleteDirectory(workspacePath); + deleteClientLog(storagePath); deleteDirectory(syntaxServerWorkspacePath); } catch (error) { data['error'] = getMessage(error); @@ -1049,3 +1050,5 @@ function registerRestartJavaLanguageServerCommand(context: ExtensionContext) { } })); } + + diff --git a/src/utils.ts b/src/utils.ts index 61477829d1..b68b010bb9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -35,6 +35,19 @@ export function deleteDirectory(dir) { } } +export function deleteClientLog(dir) { + if (fs.existsSync(dir)) { + fs.readdirSync(dir).forEach((child) => { + if (child.startsWith('client.log') || child.endsWith('audit.json')) { + const entry = path.join(dir, child); + if (!fs.lstatSync(entry).isDirectory()) { + fs.unlinkSync(entry); + } + } + }); + } +} + export function getTimestamp(file) { if (!fs.existsSync(file)) { return -1;