HDDS-210. Make "-file" argument optional for ozone getKey command. Contributed by Lokesh Jain.
This commit is contained in:
parent
88625f5cd9
commit
103f2eeb57
@ -705,6 +705,18 @@ public void testGetKey() throws Exception {
|
||||
randFile.read(dataBytes);
|
||||
}
|
||||
assertEquals(dataStr, DFSUtil.bytes2String(dataBytes));
|
||||
|
||||
tmpPath = baseDir.getAbsolutePath() + File.separatorChar + keyName;
|
||||
args = new String[] {"-getKey",
|
||||
url + "/" + volumeName + "/" + bucketName + "/" + keyName, "-file",
|
||||
baseDir.getAbsolutePath()};
|
||||
assertEquals(0, ToolRunner.run(shell, args));
|
||||
|
||||
dataBytes = new byte[dataStr.length()];
|
||||
try (FileInputStream randFile = new FileInputStream(new File(tmpPath))) {
|
||||
randFile.read(dataBytes);
|
||||
}
|
||||
assertEquals(dataStr, DFSUtil.bytes2String(dataBytes));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -98,11 +98,14 @@ protected void execute(CommandLine cmd)
|
||||
Path dataFilePath = Paths.get(fileName);
|
||||
File dataFile = new File(fileName);
|
||||
|
||||
if (dataFile.exists() && dataFile.isDirectory()) {
|
||||
dataFile = new File(fileName, keyName);
|
||||
}
|
||||
|
||||
if (dataFile.exists()) {
|
||||
throw new OzoneClientException(fileName +
|
||||
"exists. Download will overwrite an " +
|
||||
"existing file. Aborting.");
|
||||
throw new OzoneClientException(
|
||||
fileName + "exists. Download will overwrite an "
|
||||
+ "existing file. Aborting.");
|
||||
}
|
||||
|
||||
OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
|
||||
|
Loading…
Reference in New Issue
Block a user