-
Notifications
You must be signed in to change notification settings - Fork 115
Convert input handling based on CCSID scenarios #2556
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
Draft
worksofliam
wants to merge
8
commits into
master
Choose a base branch
from
fix/convert_basis_by_basis
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f1e5e24
Convert different types of input based on the CCSID in different scen…
worksofliam 39a5873
Change check for posix path conversion
worksofliam a68547c
Merge branch 'master' into fix/convert_basis_by_basis
worksofliam 9ad5212
Additional test cases for download member
worksofliam 3b26646
Sanitize Object Names to support local variants
worksofliam 7bcbb3c
Correctly add missing double quotes where required
worksofliam c2e03f1
Fix for count members with variants
worksofliam 79e49f1
Escape the paths correctly when building a QSYS path
worksofliam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -167,7 +167,7 @@ export default class IBMiContent { | |||||
const member = this.ibmi.upperCaseName(smallSignature ? sourceFileOrMember : String(memberOrLocalPath)); | ||||||
|
||||||
const asp = await this.ibmi.lookupLibraryIAsp(library); | ||||||
const path = Tools.qualifyPath(library, sourceFile, member, asp, true); | ||||||
const path = Tools.qualifyPath(library, sourceFile, member, asp); | ||||||
const tempRmt = this.getTempRemote(path); | ||||||
let retry = false; | ||||||
while (true) { | ||||||
|
@@ -255,7 +255,7 @@ export default class IBMiContent { | |||||
|
||||||
try { | ||||||
await writeFileAsync(tmpobj, content || memberOrContent, `utf8`); | ||||||
const path = Tools.qualifyPath(library, sourceFile, member, asp, true); | ||||||
const path = Tools.qualifyPath(library, sourceFile, member, asp); | ||||||
const tempRmt = this.getTempRemote(path); | ||||||
await client.putFile(tmpobj, tempRmt); | ||||||
|
||||||
|
@@ -871,27 +871,31 @@ export default class IBMiContent { | |||||
} | ||||||
|
||||||
async memberResolve(member: string, files: QsysPath[]): Promise<IBMiMember | undefined> { | ||||||
const inAmerican = (s: string) => { return this.ibmi.sysNameInAmerican(s) }; | ||||||
const inLocal = (s: string) => { return this.ibmi.sysNameInLocal(s) }; | ||||||
const localVariants = this.ibmi.variantChars; | ||||||
const forSystem = (s: string) => { return this.ibmi.sysNameInAmerican(s, this.ibmi.qsysPosixPathsRequireTranslation) }; | ||||||
const fromSystem = (s: string) => { return this.ibmi.qsysPosixPathsRequireTranslation ? this.ibmi.sysNameInLocal(s) : s }; | ||||||
|
||||||
// Escape names for shell | ||||||
const pathList = files | ||||||
.map(file => { | ||||||
const asp = file.asp || this.ibmi.getCurrentIAspName(); | ||||||
if (asp && asp.length > 0) { | ||||||
return [ | ||||||
Tools.qualifyPath(inAmerican(file.library), inAmerican(file.name), inAmerican(member), asp, true), | ||||||
Tools.qualifyPath(inAmerican(file.library), inAmerican(file.name), inAmerican(member), undefined, true) | ||||||
Tools.qualifyPath(forSystem(file.library), forSystem(file.name), forSystem(member), asp, localVariants), | ||||||
Tools.qualifyPath(fromSystem(file.library), fromSystem(file.name), fromSystem(member), undefined, localVariants) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It used to be
Suggested change
|
||||||
].join(` `); | ||||||
} else { | ||||||
return Tools.qualifyPath(inAmerican(file.library), inAmerican(file.name), inAmerican(member), undefined, true); | ||||||
return Tools.qualifyPath(forSystem(file.library), forSystem(file.name), forSystem(member), undefined, localVariants); | ||||||
} | ||||||
}) | ||||||
.map( | ||||||
path => IBMi.escapeForShell(path) | ||||||
) | ||||||
.join(` `) | ||||||
.toUpperCase(); | ||||||
|
||||||
const command = `for f in ${pathList}; do if [ -f $f ]; then echo $f; break; fi; done`; | ||||||
const result = await this.ibmi.sendCommand({ | ||||||
const result = await this.ibmi.sendQsh({ | ||||||
command, | ||||||
}); | ||||||
|
||||||
|
@@ -900,7 +904,7 @@ export default class IBMiContent { | |||||
|
||||||
if (firstMost) { | ||||||
try { | ||||||
const simplePath = inLocal(Tools.unqualifyPath(firstMost)); | ||||||
const simplePath = fromSystem(Tools.unqualifyPath(firstMost)); | ||||||
|
||||||
// This can error if the path format is wrong for some reason. | ||||||
// Not that this would ever happen, but better to be safe than sorry | ||||||
|
@@ -915,7 +919,10 @@ export default class IBMiContent { | |||||
} | ||||||
|
||||||
async objectResolve(object: string, libraries: string[]): Promise<string | undefined> { | ||||||
const command = `for f in ${libraries.map(lib => `/QSYS.LIB/${this.ibmi.sysNameInAmerican(lib)}.LIB/${this.ibmi.sysNameInAmerican(object)}.*`).join(` `)}; do if [ -f $f ] || [ -d $f ]; then echo $f; break; fi; done`; | ||||||
const forSystem = (s: string) => { return Tools.escapePath(this.ibmi.sysNameInAmerican(s, this.ibmi.qsysPosixPathsRequireTranslation)) }; | ||||||
const fromSystem = (s: string) => { return this.ibmi.qsysPosixPathsRequireTranslation ? this.ibmi.sysNameInLocal(s) : s }; | ||||||
|
||||||
const command = `for f in ${libraries.map(lib => `/QSYS.LIB/${forSystem(lib)}.LIB/${forSystem(object)}.*`).join(` `)}; do if [ -f $f ] || [ -d $f ]; then echo $f; break; fi; done`; | ||||||
|
||||||
const result = await this.ibmi.sendCommand({ | ||||||
command, | ||||||
|
@@ -925,7 +932,7 @@ export default class IBMiContent { | |||||
const firstMost = result.stdout; | ||||||
|
||||||
if (firstMost) { | ||||||
const lib = this.ibmi.sysNameInLocal(Tools.unqualifyPath(firstMost)); | ||||||
const lib = fromSystem(Tools.unqualifyPath(firstMost)); | ||||||
|
||||||
return lib.split('/')[1]; | ||||||
} | ||||||
|
@@ -1035,11 +1042,11 @@ export default class IBMiContent { | |||||
|
||||||
if (assumeMember) { | ||||||
// If it's an object, we assume it's a member, therefore let's let qsh handle it (better for variants) | ||||||
localPath.asp = localPath.asp ? this.ibmi.sysNameInAmerican(localPath.asp) : undefined; | ||||||
localPath.library = this.ibmi.sysNameInAmerican(localPath.library); | ||||||
localPath.name = this.ibmi.sysNameInAmerican(localPath.name); | ||||||
localPath.member = localPath.member ? this.ibmi.sysNameInAmerican(localPath.member) : undefined; | ||||||
target = Tools.qualifyPath(localPath.library, localPath.name, localPath.member || '', localPath.asp || '', true); | ||||||
target = Tools.qualifyPath(localPath.library, localPath.name, localPath.member || '', localPath.asp || '', this.ibmi.variantChars); | ||||||
|
||||||
if (this.ibmi.qsysPosixPathsRequireTranslation) { | ||||||
target = this.ibmi.sysNameInAmerican(target); | ||||||
} | ||||||
} else { | ||||||
target = localPath; | ||||||
} | ||||||
|
@@ -1067,11 +1074,18 @@ export default class IBMiContent { | |||||
} | ||||||
|
||||||
async countMembers(path: QsysPath) { | ||||||
return this.countFiles(this.ibmi.sysNameInAmerican(Tools.qualifyPath(path.library, path.name, undefined, path.asp))) | ||||||
return this.countFiles(this.ibmi.sysNameInAmerican( | ||||||
Tools.qualifyPath(path.library, path.name, undefined, path.asp), | ||||||
this.ibmi.qsysPosixPathsRequireTranslation | ||||||
), true); | ||||||
} | ||||||
|
||||||
async countFiles(directory: string) { | ||||||
return Number((await this.ibmi.sendCommand({ command: `cd "${directory}" && (ls | wc -l)` })).stdout.trim()); | ||||||
async countFiles(directory: string, isQsys?: boolean) { | ||||||
if (isQsys) { | ||||||
return Number((await this.ibmi.sendQsh({ command: `cd "${IBMi.escapeForShell(directory)}" && (ls | wc -l)` })).stdout.trim()); | ||||||
} else { | ||||||
return Number((await this.ibmi.sendCommand({ command: `cd "${IBMi.escapeForShell(directory)}" && (ls | wc -l)` })).stdout.trim()); | ||||||
} | ||||||
} | ||||||
|
||||||
|
||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic behind the
enabled
parameter is unclear or would need to be redefined. Looking at all the references in the code, it's always this class'qsysPosixPathsRequireTranslation
field that is used.Here is a suggestion: make that second parameter optional, and when it's
true
, considerqsysPosixPathsRequireTranslation
value. Then in the places where the method is called with the second parameter, passifNeeded
astrue
: