Skip to content

Commit

Permalink
Re-arrange download/upload member upload to correctly convert variants
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Nov 12, 2024
1 parent 5ecf64c commit 35c1e1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/api/IBMiContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export default class IBMiContent {
while (true) {
let copyResult: CommandResult;
if (this.ibmi.dangerousVariants && new RegExp(`[${this.ibmi.variantChars.local}]`).test(path)) {
library = this.ibmi.sysNameInAmerican(library);
sourceFile = this.ibmi.sysNameInAmerican(sourceFile);
member = this.ibmi.sysNameInAmerican(member);
copyResult = { code: 0, stdout: '', stderr: '' };
try {
await this.ibmi.runSQL([
Expand All @@ -167,7 +170,7 @@ export default class IBMiContent {
}
else {
copyResult = await this.ibmi.runCommand({
command: `QSYS/CPYTOSTMF FROMMBR('${path}') TOSTMF('${tempRmt}') STMFOPT(*REPLACE) STMFCCSID(1208) DBFCCSID(${this.config.sourceFileCCSID})`,
command: `QSYS/CPYTOSTMF FROMMBR('${this.ibmi.sysNameInAmerican(path)}') TOSTMF('${tempRmt}') STMFOPT(*REPLACE) STMFCCSID(1208) DBFCCSID(${this.config.sourceFileCCSID})`,
noLibList: true
});
}
Expand Down Expand Up @@ -231,6 +234,10 @@ export default class IBMiContent {
if (this.ibmi.dangerousVariants && new RegExp(`[${this.ibmi.variantChars.local}]`).test(path)) {
copyResult = { code: 0, stdout: '', stderr: '' };
try {
library = this.ibmi.sysNameInAmerican(library);
sourceFile = this.ibmi.sysNameInAmerican(sourceFile);
member = this.ibmi.sysNameInAmerican(member);

await this.ibmi.runSQL([
`@QSYS/CPYF FROMFILE(${library}/${sourceFile}) FROMMBR(${member}) TOFILE(QTEMP/QTEMPSRC) TOMBR(TEMPMEMBER) MBROPT(*REPLACE) CRTFILE(*YES);`,
`@QSYS/CPYFRMSTMF FROMSTMF('${tempRmt}') TOMBR('${Tools.qualifyPath("QTEMP", "QTEMPSRC", "TEMPMEMBER", undefined)}') MBROPT(*REPLACE) STMFCCSID(1208) DBFCCSID(${this.config.sourceFileCCSID})`,
Expand All @@ -243,7 +250,7 @@ export default class IBMiContent {
}
else {
copyResult = await this.ibmi.runCommand({
command: `QSYS/CPYFRMSTMF FROMSTMF('${tempRmt}') TOMBR('${path}') MBROPT(*REPLACE) STMFCCSID(1208) DBFCCSID(${this.config.sourceFileCCSID})`,
command: `QSYS/CPYFRMSTMF FROMSTMF('${tempRmt}') TOMBR('${this.ibmi.sysNameInAmerican(path)}') MBROPT(*REPLACE) STMFCCSID(1208) DBFCCSID(${this.config.sourceFileCCSID})`,
noLibList: true
});
}
Expand Down
7 changes: 5 additions & 2 deletions src/testing/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ export const EncodingSuite: TestSuite = {
const ccsidData = connection.getCcsids()!;

const tempLib = config.tempLibrary;
const varChar = connection.variantChars.local[0];
const varChar = connection.variantChars.local[1];

const testFile = `${varChar}SOURCES`;
const testFile = `${varChar}SCOBBY`;
const testMember = `${varChar}MEMBER`;

const attemptDelete = await connection.runCommand({ command: `DLTF FILE(${tempLib}/${connection.sysNameInAmerican(testFile)})`, noLibList: true });
Expand All @@ -206,6 +206,9 @@ export const EncodingSuite: TestSuite = {
assert.ok(members.some(m => m.name === testMember));
assert.ok(members.some(m => m.file === testFile));

const files = await connection.content.getFileList(`/QSYS.LIB/${tempLib}.LIB/${connection.sysNameInAmerican(testFile)}.FILE`);
assert.ok(files.length);

await connection.content.uploadMemberContent(undefined, tempLib, testFile, testMember, [`**free`, `dsply 'Hello world';`, `return;`].join(`\n`));

const compileResult = await connection.runCommand({ command: `CRTBNDRPG PGM(${tempLib}/${testMember}) SRCFILE(${tempLib}/${testFile}) SRCMBR(${testMember})`, noLibList: true });
Expand Down

0 comments on commit 35c1e1c

Please sign in to comment.