You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/07/15 04:51:14 UTC

[GitHub] [cassandra-sidecar] yifan-c commented on a diff in pull request #34: CASSANDRASC-40 Fix search in list snapshot endpoint

yifan-c commented on code in PR #34:
URL: https://github.com/apache/cassandra-sidecar/pull/34#discussion_r921808410


##########
src/main/java/org/apache/cassandra/sidecar/routes/ListSnapshotFilesHandler.java:
##########
@@ -130,20 +121,18 @@ private ListSnapshotFilesResponse buildResponse(String host,
                                                     ListSnapshotFilesRequest request,
                                                     List<Pair<String, FileProps>> fileList)
     {
-        InstanceMetadata instanceMetadata = instancesConfig.instanceFromHost(host);
-        int sidecarPort = instanceMetadata.port();
-        Path dataDirPath = Paths.get(instanceMetadata.dataDirs().get(DATA_DIR_INDEX));
         ListSnapshotFilesResponse response = new ListSnapshotFilesResponse();
         String snapshotName = request.getSnapshotName();
+        int sidecarPort = configuration.getPort();
 
         for (Pair<String, FileProps> file : fileList)
         {
-            Path pathFromDataDir = dataDirPath.relativize(Paths.get(file.getLeft()));
+            Path path = Paths.get(file.getLeft());
 
             String keyspace = request.getKeyspace();
             // table name might include a dash (-) with the table UUID so we always use it as part of the response
-            String tableName = pathFromDataDir.getName(TABLE_NAME_SUBPATH_INDEX).toString();
-            String fileName = pathFromDataDir.getName(FILE_NAME_SUBPATH_INDEX).toString();
+            String tableName = path.getName(path.getNameCount() - TABLE_NAME_SUBPATH_INDEX_FROM_END).toString();

Review Comment:
   Counting from the end... does it work if includeSecondaryIndexFiles? It would add another level



##########
src/main/java/org/apache/cassandra/sidecar/routes/ListSnapshotFilesHandler.java:
##########
@@ -130,20 +121,18 @@ private ListSnapshotFilesResponse buildResponse(String host,
                                                     ListSnapshotFilesRequest request,
                                                     List<Pair<String, FileProps>> fileList)
     {
-        InstanceMetadata instanceMetadata = instancesConfig.instanceFromHost(host);
-        int sidecarPort = instanceMetadata.port();
-        Path dataDirPath = Paths.get(instanceMetadata.dataDirs().get(DATA_DIR_INDEX));
         ListSnapshotFilesResponse response = new ListSnapshotFilesResponse();
         String snapshotName = request.getSnapshotName();
+        int sidecarPort = configuration.getPort();

Review Comment:
   👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org