Skip to content

Commit

Permalink
encoding fix
Browse files Browse the repository at this point in the history
Signed-off-by: jace-roell <jace.roell@hotmail.com>
  • Loading branch information
jace-roell committed Oct 30, 2024
1 parent bc3598f commit e0a653b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
*.bin binary binary
*.jcl IBM-1047 IBM-1047
*.md UTF-8 UTF-8
*.txt UTF-8 IBM-1047
*.txt UTF-8 IBM-1147
25 changes: 11 additions & 14 deletions packages/zosfiles/src/methods/upload/Upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,30 +860,27 @@ export class Upload {
ussPath: string,
options: IUploadOptions
): Promise<IZosFilesResponse> {
const tempOptions: Partial<IUploadOptions> = { ...options };
const tempOptions: IUploadOptions = { ...options };
if (options.attributes) {
if (!options.attributes.fileShouldBeUploaded(localPath)) {
return;
}
tempOptions.binary = options.attributes.getFileTransferMode(localPath, options.binary) === TransferMode.BINARY;
const remoteEncoding = options.attributes.getRemoteEncoding(localPath);
if (remoteEncoding != null && remoteEncoding !== Tag.BINARY) {
tempOptions.encoding = remoteEncoding;
}

if(remoteEncoding === Tag.BINARY) tempOptions.encoding = undefined;
else if(remoteEncoding !== null) tempOptions.encoding = remoteEncoding

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (90% of all statements in
the enclosing function
have an explicit semicolon).

if (!tempOptions.binary) {
tempOptions.localEncoding = options.attributes.getLocalEncoding(localPath);
}
} else {
if (options.filesMap) {
if (options.filesMap.fileNames.indexOf(path.basename(localPath)) > -1) {
tempOptions.binary = options.filesMap.binary;
} else {
tempOptions.binary = options.binary;
}
} else {
tempOptions.binary = options.binary;
}
} else if(options.filesMap && options.filesMap.fileNames.indexOf(path.basename(localPath)) > -1) {
tempOptions.binary = options.filesMap.binary;

Check warning on line 878 in packages/zosfiles/src/methods/upload/Upload.ts

View check run for this annotation

Codecov / codecov/patch

packages/zosfiles/src/methods/upload/Upload.ts#L878

Added line #L878 was not covered by tests

// Reset encoding to undefined if binary is true to avoid file tagging issues
if(tempOptions.binary) tempOptions.encoding = undefined;
}

return await this.fileToUssFile(session, localPath, ussPath, tempOptions);
}

Expand Down

0 comments on commit e0a653b

Please sign in to comment.