From 4de8c5fee4ac0cdbe42f7a61c632ae3fe46e16a1 Mon Sep 17 00:00:00 2001 From: Seb Julliand Date: Sat, 18 Nov 2023 22:53:25 +0100 Subject: [PATCH 1/3] Set working dir to home if deleting working dir Signed-off-by: Seb Julliand --- src/locale/ids/da.ts | 1 + src/locale/ids/en.ts | 1 + src/locale/ids/fr.ts | 1 + src/views/ifsBrowser.ts | 13 +++++++++++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/locale/ids/da.ts b/src/locale/ids/da.ts index 3dfc0a1c3..c41745c14 100644 --- a/src/locale/ids/da.ts +++ b/src/locale/ids/da.ts @@ -75,6 +75,7 @@ export const da: Locale = { 'ifsBrowser.deleteIFS.infoMessage': `Slettede {0}.`, 'ifsBrowser.deleteIFS.errorMessage': `Fejl ved sletning af streamfile! {0}`, 'ifsBrowser.deleteIFS.cancelled': `Sletning afbrudt.`, + 'ifsBrowser.deleteIFS.default.home.dir':'{0} was the working directory; it is now {1}.', 'ifsBrowser.moveIFS.prompt': `Nyt navn`, 'ifsBrowser.moveIFS.errorMessage': `Fejl ved flytning/omdøbning af {0}! {1}`, 'ifsBrowser.moveIFS.renamed': `{0} blev omdøbt til {1}.`, diff --git a/src/locale/ids/en.ts b/src/locale/ids/en.ts index af352577b..c9d728713 100644 --- a/src/locale/ids/en.ts +++ b/src/locale/ids/en.ts @@ -75,6 +75,7 @@ export const en: Locale = { 'ifsBrowser.deleteIFS.infoMessage': `Deleted {0}.`, 'ifsBrowser.deleteIFS.errorMessage': `Error deleting streamfile! {0}`, 'ifsBrowser.deleteIFS.cancelled': `Deletion canceled.`, + 'ifsBrowser.deleteIFS.default.home.dir':'{0} was the working directory; it is now {1}.', 'ifsBrowser.moveIFS.prompt': `Name of new path`, 'ifsBrowser.moveIFS.errorMessage': `Error renaming/moving {0}! {1}`, 'ifsBrowser.moveIFS.renamed': `{0} was renamed to {1}.`, diff --git a/src/locale/ids/fr.ts b/src/locale/ids/fr.ts index 598354cc1..692c41408 100644 --- a/src/locale/ids/fr.ts +++ b/src/locale/ids/fr.ts @@ -75,6 +75,7 @@ export const fr: Locale = { 'ifsBrowser.deleteIFS.infoMessage': `{0} supprimé.`, 'ifsBrowser.deleteIFS.errorMessage': `Erreur lors de la suppression du fichier! {0}`, 'ifsBrowser.deleteIFS.cancelled': `Suppression annulée.`, + 'ifsBrowser.deleteIFS.default.home.dir':'{0} était le répertoire de travail; c\'est désormais {1}.', 'ifsBrowser.moveIFS.prompt': `Nouveau chemin`, 'ifsBrowser.moveIFS.errorMessage': `Erreur lors du renommage/déplacement de {0}! {1}`, 'ifsBrowser.moveIFS.renamed': `{0} a été renommé {1}.`, diff --git a/src/views/ifsBrowser.ts b/src/views/ifsBrowser.ts index bb5be50ae..31736e869 100644 --- a/src/views/ifsBrowser.ts +++ b/src/views/ifsBrowser.ts @@ -388,7 +388,8 @@ export function initializeIFSBrowser(context: vscode.ExtensionContext) { vscode.commands.registerCommand(`code-for-ibmi.deleteIFS`, async (node: IFSItem) => { const connection = instance.getConnection(); - if (connection) { + const config = instance.getConfig(); + if (connection && config) { if (node.path !== `/`) { let deletionConfirmed = false; const proceed = await vscode.window.showWarningMessage(t(`ifsBrowser.deleteIFS.warningMessage`, node.path), t(`Yes`), t(`Cancel`)) === t(`Yes`); @@ -413,7 +414,15 @@ export function initializeIFSBrowser(context: vscode.ExtensionContext) { if (deletionConfirmed) { try { - await connection.sendCommand({ command: `rm -rf ${Tools.escapePath(node.path)}` }) + if(config.homeDirectory === node.path){ + const echoHome = await connection.sendCommand({ command: `echo $HOME` }); + if(echoHome.code === 0){ + config.homeDirectory = echoHome.stdout.trim(); + await ConnectionConfiguration.update(config); + vscode.window.showInformationMessage(t('ifsBrowser.deleteIFS.default.home.dir', node.path, config.homeDirectory)); + } + } + await connection.sendCommand({ command: `rm -rf ${Tools.escapePath(node.path)}` }) vscode.window.showInformationMessage(t(`ifsBrowser.deleteIFS.infoMessage`, node.path)); if (GlobalConfiguration.get(`autoRefresh`)) { ifsBrowser.refresh(node.parent); From e1503f9b4da5cede3ea739e0e40f0e9dcbb466d6 Mon Sep 17 00:00:00 2001 From: Seb Julliand Date: Sat, 18 Nov 2023 22:54:42 +0100 Subject: [PATCH 2/3] Check IFS delete and show error in case of failure Signed-off-by: Seb Julliand --- src/views/ifsBrowser.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/views/ifsBrowser.ts b/src/views/ifsBrowser.ts index 31736e869..62f1991c3 100644 --- a/src/views/ifsBrowser.ts +++ b/src/views/ifsBrowser.ts @@ -422,8 +422,13 @@ export function initializeIFSBrowser(context: vscode.ExtensionContext) { vscode.window.showInformationMessage(t('ifsBrowser.deleteIFS.default.home.dir', node.path, config.homeDirectory)); } } - await connection.sendCommand({ command: `rm -rf ${Tools.escapePath(node.path)}` }) - vscode.window.showInformationMessage(t(`ifsBrowser.deleteIFS.infoMessage`, node.path)); + const removeResult = await connection.sendCommand({ command: `rm -rf ${Tools.escapePath(node.path)}` }) + if(removeResult.code === 0){ + vscode.window.showInformationMessage(t(`ifsBrowser.deleteIFS.infoMessage`, node.path)); + } + else{ + throw removeResult.stderr; + } if (GlobalConfiguration.get(`autoRefresh`)) { ifsBrowser.refresh(node.parent); } From 85b959b4c6117d2ab1da6318258882775bbf3aac Mon Sep 17 00:00:00 2001 From: Christian Jorgensen Date: Sat, 18 Nov 2023 23:33:35 +0100 Subject: [PATCH 3/3] Add Danish translation for deleting working directory --- src/locale/ids/da.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locale/ids/da.ts b/src/locale/ids/da.ts index c41745c14..bb7a91b5c 100644 --- a/src/locale/ids/da.ts +++ b/src/locale/ids/da.ts @@ -75,7 +75,7 @@ export const da: Locale = { 'ifsBrowser.deleteIFS.infoMessage': `Slettede {0}.`, 'ifsBrowser.deleteIFS.errorMessage': `Fejl ved sletning af streamfile! {0}`, 'ifsBrowser.deleteIFS.cancelled': `Sletning afbrudt.`, - 'ifsBrowser.deleteIFS.default.home.dir':'{0} was the working directory; it is now {1}.', + 'ifsBrowser.deleteIFS.default.home.dir':'{0} var den aktuelle mappe; det er nu {1}.', 'ifsBrowser.moveIFS.prompt': `Nyt navn`, 'ifsBrowser.moveIFS.errorMessage': `Fejl ved flytning/omdøbning af {0}! {1}`, 'ifsBrowser.moveIFS.renamed': `{0} blev omdøbt til {1}.`,