diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 4f880969c7..d2627aa2ef 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to the Zowe CLI package will be documented in this file. - Enhancement: Incorporate all source code from the zowe/imperative Github repository into the zowe/zowe-cli repository. This change should have no user impact. - BugFix: Removed out of date `Perf-Timing` performance timing package. +- BugFix: Fix behavior where a specified directory was being lowercased on non-PDS datasets when downloading all datasets [#1722](https://github.com/zowe/zowe-cli/issues/1722) ## `7.18.8` diff --git a/packages/zosfiles/CHANGELOG.md b/packages/zosfiles/CHANGELOG.md index ef84ef1cc7..1db6d1a262 100644 --- a/packages/zosfiles/CHANGELOG.md +++ b/packages/zosfiles/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe z/OS files SDK package will be documented in this file. +## Recent Changes + +- BugFix: Fix behavior where a specified directory was being lowercased on non-PDS datasets when downloading all datasets [#1722](https://github.com/zowe/zowe-cli/issues/1722) + ## `7.18.8` - Enhancement: Patch that adds invalidFileName to ZosFilesMessages diff --git a/packages/zosfiles/__tests__/__unit__/methods/download/Download.unit.test.ts b/packages/zosfiles/__tests__/__unit__/methods/download/Download.unit.test.ts index 27bcc89211..671b2a7deb 100644 --- a/packages/zosfiles/__tests__/__unit__/methods/download/Download.unit.test.ts +++ b/packages/zosfiles/__tests__/__unit__/methods/download/Download.unit.test.ts @@ -870,6 +870,39 @@ describe("z/OS Files - Download", () => { }); }); + it("should download all members specifying mixed case directory, volume, and extension", async () => { + let response; + let caughtError; + + const volume = "testVs"; + const directory = "My/Test/Path/"; + const extension = ".xyz"; + + try { + response = await Download.allMembers(dummySession, dsname, {volume, directory, extension}); + } catch (e) { + caughtError = e; + } + + expect(caughtError).toBeUndefined(); + expect(response).toEqual({ + success: true, + commandResponse: util.format(ZosFilesMessages.datasetDownloadedWithDestination.message, directory), + apiResponse: listApiResponse + }); + + expect(listAllMembersSpy).toHaveBeenCalledTimes(1); + expect(listAllMembersSpy).toHaveBeenCalledWith(dummySession, dsname, {volume}); + + expect(downloadDatasetSpy).toHaveBeenCalledTimes(2); + listApiResponse.items.forEach((mem) => { + expect(downloadDatasetSpy).toHaveBeenCalledWith(dummySession, `${dsname}(${mem.member})`, { + volume, + file: `${directory}/${mem.member.toLowerCase()}${extension}` + }); + }); + }); + it("should download all members with specified \"\" extension", async () => { let response; let caughtError; @@ -1279,6 +1312,42 @@ describe("z/OS Files - Download", () => { expect(Download.dataSet).toHaveBeenCalledWith(dummySession, dataSetPS.dsname, {file: "my/test/path/test.ps.data.set.xyz"}); }); + it("should download all datasets specifying a mixed case directory", async () => { + let response; + let caughtError; + + const directory = "My/Test/Path"; + const extensionMap = {set: "file"}; + + Download.dataSet = jest.fn(async (): Promise => { + return { + commandResponse: "Data set downloaded", + apiResponse: { + items: [dataSetPS] + }, + }; + }); + + try { + response = await Download.allDataSets(dummySession, [dataSetPS] as any, {directory, extensionMap}); + } catch (e) { + caughtError = e; + } + + expect(caughtError).toBeUndefined(); + expect(response).toEqual({ + success: true, + commandResponse: (Download as any).buildDownloadDsmResponse({ + downloaded: ["TEST.PS.DATA.SET"], + failedArchived: [], + failedUnsupported: [], + failedWithErrors: {} + }, {directory}), + apiResponse: [{ ...dataSetPS, status: "Data set downloaded" }] + }); + expect(Download.dataSet).toHaveBeenCalledWith(dummySession, dataSetPS.dsname, {extensionMap, file: "My/Test/Path/test.ps.data.set.file"}); + }); + it("should download all datasets specifying the directory and extension map 1", async () => { let response; let caughtError; diff --git a/packages/zosfiles/src/methods/download/Download.ts b/packages/zosfiles/src/methods/download/Download.ts index 3dd345ac4d..135b76a3c4 100644 --- a/packages/zosfiles/src/methods/download/Download.ts +++ b/packages/zosfiles/src/methods/download/Download.ts @@ -372,11 +372,11 @@ export class Download { } else if (dataSetObj.dsorg === "PO" || dataSetObj.dsorg === "PO-E") { mutableOptions.directory = `${mutableOptions.directory}/${ZosFilesUtils.getDirsFromDataSet(dataSetObj.dsname)}`; } else { - mutableOptions.file = `${mutableOptions.directory}/${dataSetObj.dsname}.` + - `${mutableOptions.extension ?? ZosFilesUtils.DEFAULT_FILE_EXTENSION}`; + mutableOptions.file = `${dataSetObj.dsname}.${mutableOptions.extension ?? ZosFilesUtils.DEFAULT_FILE_EXTENSION}`; if (!options.preserveOriginalLetterCase) { mutableOptions.file = mutableOptions.file.toLowerCase(); } + mutableOptions.file = `${mutableOptions.directory}/${mutableOptions.file}`; mutableOptions.directory = undefined; mutableOptions.extension = undefined; }