Skip to content

Commit

Permalink
HDDS-12057. ReadReplicas should handle key names containing / (#7735)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptlrs authored Jan 22, 2025
1 parent bb96826 commit 642b1c7
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ protected void execute(OzoneClient client, OzoneAddress address)
String volumeName = address.getVolumeName();
String bucketName = address.getBucketName();
String keyName = address.getKeyName();
// Multilevel keys will have a '/' in their names. This interferes with
// directory and file creation process. Flatten the keys to fix this.
String sanitizedKeyName = address.getKeyName().replace("/", "_");

File dir = createDirectory(volumeName, bucketName, keyName);
File dir = createDirectory(volumeName, bucketName, sanitizedKeyName);

OzoneKeyDetails keyInfoDetails
= checksumClient.getKeyDetails(volumeName, bucketName, keyName);
Expand All @@ -128,13 +131,13 @@ protected void execute(OzoneClient client, OzoneAddress address)
result.put(JSON_PROPERTY_FILE_SIZE, keyInfoDetails.getDataSize());

ArrayNode blocks = JsonUtils.createArrayNode();
downloadReplicasAndCreateManifest(keyName, replicas,
downloadReplicasAndCreateManifest(sanitizedKeyName, replicas,
replicasWithoutChecksum, dir, blocks);
result.set(JSON_PROPERTY_FILE_BLOCKS, blocks);

String prettyJson = JsonUtils.toJsonStringWithDefaultPrettyPrinter(result);

String manifestFileName = keyName + "_manifest";
String manifestFileName = sanitizedKeyName + "_manifest";
System.out.println("Writing manifest file : " + manifestFileName);
File manifestFile
= new File(dir, manifestFileName);
Expand Down

0 comments on commit 642b1c7

Please sign in to comment.