Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deletion current directory and check error #1658

Merged
merged 3 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/locale/ids/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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} 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}.`,
Expand Down
1 change: 1 addition & 0 deletions src/locale/ids/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}.`,
Expand Down
1 change: 1 addition & 0 deletions src/locale/ids/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}.`,
Expand Down
20 changes: 17 additions & 3 deletions src/views/ifsBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand All @@ -413,8 +414,21 @@ export function initializeIFSBrowser(context: vscode.ExtensionContext) {

if (deletionConfirmed) {
try {
await connection.sendCommand({ command: `rm -rf ${Tools.escapePath(node.path)}` })
vscode.window.showInformationMessage(t(`ifsBrowser.deleteIFS.infoMessage`, 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));
}
}
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);
}
Expand Down