Skip to content

Commit

Permalink
Fix cf name extraction from manifest in Directories.migrateFile()
Browse files Browse the repository at this point in the history
patch by Marcus Eriksson; reviewed by Aleksey Yeschenko for
CASSANDRA-5242
  • Loading branch information
iamaleksey committed Apr 2, 2013
1 parent b4d26bb commit d4744e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Add UseTLAB JVM flag (CASSANDRA-5361)
* cli: Quote ks and cf names in schema output when needed (CASSANDRA-5052)
* Fix bad default for min/max timestamp in SSTableMetadata (CASSANDRA-5372)
* Fix cf name extraction from manifest in Directories.migrateFile() (CASSANDRA-5242)


1.1.10
Expand Down
10 changes: 9 additions & 1 deletion src/java/org/apache/cassandra/db/Directories.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ private static void migrateFile(File file, File ksDir, String additionalPath)
String name = file.getName();
boolean isManifest = name.endsWith(LeveledManifest.EXTENSION);
String cfname = isManifest
? name.substring(0, name.length() - LeveledManifest.EXTENSION.length())
? getCfNameFromManifest(name)
: name.substring(0, name.indexOf(Component.separator));

int idx = cfname.indexOf(SECONDARY_INDEX_NAME_SEPARATOR); // idx > 0 => secondary index
Expand All @@ -571,6 +571,14 @@ private static void migrateFile(File file, File ksDir, String additionalPath)
}
}

private static String getCfNameFromManifest(String name)
{
String withoutExt = name.substring(0, name.length() - LeveledManifest.EXTENSION.length());
return withoutExt.endsWith("-old") || withoutExt.endsWith("-tmp")
? withoutExt.substring(0, withoutExt.length() - 4)
: withoutExt;
}

// Hack for tests, don't use otherwise
static void overrideDataDirectoriesForTest(String loc)
{
Expand Down

0 comments on commit d4744e1

Please sign in to comment.