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 path splitting when opening a member on an IASP #1768

Merged
merged 1 commit into from
Jan 8, 2024
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
8 changes: 4 additions & 4 deletions src/api/IBMiContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import fs from 'fs';
import path from 'path';
import tmp from 'tmp';
import util from 'util';
import { window } from 'vscode';
import { ObjectTypes } from '../filesystems/qsys/Objects';
import { CommandResult, IBMiError, IBMiFile, IBMiMember, IBMiObject, IFSFile, QsysPath } from '../typings';
import { ConnectionConfiguration } from './Configuration';
import { default as IBMi } from './IBMi';
import { Tools } from './Tools';
import { window } from 'vscode';
const tmpFile = util.promisify(tmp.file);
const readFileAsync = util.promisify(fs.readFile);
const writeFileAsync = util.promisify(fs.writeFile);
Expand Down Expand Up @@ -861,9 +861,9 @@ export default class IBMiContent {
if (path.startsWith('/')) { //IFS path
return this.config.protectedPaths.some(p => path.startsWith(p));
}
else { //QSYS path
const [library] = path.split('/');
return this.config.protectedPaths.includes(library.toLocaleUpperCase());
else { //QSYS path
const qsysObject = Tools.parseQSysPath(path);
return this.config.protectedPaths.includes(qsysObject.library.toLocaleUpperCase());
}
}
}
19 changes: 18 additions & 1 deletion src/api/Tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Crypto from 'crypto';
import { readFileSync } from "fs";
import path from "path";
import vscode from "vscode";
import { IBMiMessage, IBMiMessages } from '../typings';
import { IBMiMessage, IBMiMessages, QsysPath } from '../typings';
import { API, GitExtension } from "./import/git";

export namespace Tools {
Expand Down Expand Up @@ -235,4 +235,21 @@ export namespace Tools {
findId: id => messages.find(m => m.id === id)
}
}

export function parseQSysPath(path: string) : QsysPath{
const parts = path.split('/');
if(parts.length > 3){
return {
asp: parts[0],
library: parts[1],
name: parts[2]
}
}
else{
return {
library: parts[0],
name: parts[1]
}
}
}
}
34 changes: 17 additions & 17 deletions src/instantiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export async function loadAllofExtension(context: vscode.ExtensionContext) {
options.readonly = !await instance.getContent()?.testStreamFile(path, "w");
}
else {
const [library, name] = path.split('/');
const writable = await instance.getContent()?.checkObject({ library, name, type: '*FILE' }, "*UPD");
const qsysObject = Tools.parseQSysPath(path);
const writable = await instance.getContent()?.checkObject({ library: qsysObject.library, name: qsysObject.name, type: '*FILE' }, "*UPD");
if (!writable) {
options.readonly = true;
}
Expand Down Expand Up @@ -707,19 +707,19 @@ async function createQuickPickItemsList(
labelFiltered: string = ``, filtered: vscode.QuickPickItem[] = [],
labelRecent: string = ``, recent: vscode.QuickPickItem[] = [],
labelCached: string = ``, cached: vscode.QuickPickItem[] = [],
) {
const clearRecentArray = [{ label: ``, kind: vscode.QuickPickItemKind.Separator }, { label: CLEAR_RECENT }];
const clearCachedArray = [{ label: ``, kind: vscode.QuickPickItemKind.Separator }, { label: CLEAR_CACHED }];

const returnedList: vscode.QuickPickItem[] = [
{ label: labelFiltered, kind: vscode.QuickPickItemKind.Separator },
...filtered,
{ label: labelRecent, kind: vscode.QuickPickItemKind.Separator },
...recent,
...(recent.length != 0 ? clearRecentArray : []),
{ label: labelCached, kind: vscode.QuickPickItemKind.Separator },
...cached,
...(cached.length != 0 ? clearCachedArray : [])
];
return returnedList;
) {
const clearRecentArray = [{ label: ``, kind: vscode.QuickPickItemKind.Separator }, { label: CLEAR_RECENT }];
const clearCachedArray = [{ label: ``, kind: vscode.QuickPickItemKind.Separator }, { label: CLEAR_CACHED }];

const returnedList: vscode.QuickPickItem[] = [
{ label: labelFiltered, kind: vscode.QuickPickItemKind.Separator },
...filtered,
{ label: labelRecent, kind: vscode.QuickPickItemKind.Separator },
...recent,
...(recent.length != 0 ? clearRecentArray : []),
{ label: labelCached, kind: vscode.QuickPickItemKind.Separator },
...cached,
...(cached.length != 0 ? clearCachedArray : [])
];
return returnedList;
}