Skip to content

Commit

Permalink
Delete client log files when deleting workspace
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
  • Loading branch information
snjeza committed Nov 2, 2023
1 parent 31f7f3f commit c5e6309
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -321,6 +321,7 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
try {
cleanupLombokCache(context);
deleteDirectory(workspacePath);
deleteClientLog(storagePath);
deleteDirectory(syntaxServerWorkspacePath);
} catch (error) {
data['error'] = getMessage(error);
Expand Down Expand Up @@ -1049,3 +1050,5 @@ function registerRestartJavaLanguageServerCommand(context: ExtensionContext) {
}
}));
}


13 changes: 13 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c5e6309

Please sign in to comment.