From 2589273539ab10eefb5c871bca021a0911cf5def Mon Sep 17 00:00:00 2001 From: Rahul Singh Date: Tue, 5 Mar 2024 18:15:47 +0530 Subject: [PATCH] Added snapshot file changes --- .github/workflows/main.yml | 1 + src/java/org/apache/cassandra/db/Directories.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 16905696b65b..70a1ba84ba12 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,7 @@ on: - juspay-4.2 - cassandra-4.1 - feature/cassandra-4-1-5 + - feature/with-snapshot-changes jobs: build: runs-on: ubuntu-latest diff --git a/src/java/org/apache/cassandra/db/Directories.java b/src/java/org/apache/cassandra/db/Directories.java index b16dd972f10d..551708040f09 100644 --- a/src/java/org/apache/cassandra/db/Directories.java +++ b/src/java/org/apache/cassandra/db/Directories.java @@ -559,15 +559,20 @@ public static File getSnapshotDirectory(Descriptor desc, String snapshotName) * @param snapshotName snapshot name * @return directory to write snapshot */ - public static File getSnapshotDirectory(File location, String snapshotName) + public static File getSnapshotDirectory(File originalLocation, String snapshotName) { + // Getting data directory + File location = new File(originalLocation.toString().replaceFirst("(.+)/([^/]+)/([^/]+)$", "$1")); + // Getting keyspace & table direct name + String keyspaceTable = originalLocation.toString().replaceFirst("(.+)/(([^/]+)/([^/]+))$", "$2"); + if (isSecondaryIndexFolder(location)) { return getOrCreate(location.parent(), SNAPSHOT_SUBDIR, snapshotName, location.name()); } else { - return getOrCreate(location, SNAPSHOT_SUBDIR, snapshotName); + return getOrCreate(location, SNAPSHOT_SUBDIR, snapshotName, keyspaceTable); } }