Fixing error in ParseFileName causing DestroyDB to fail on archive directory

Summary:
This careless error was causing ASSERT_OK(DestroyDB) to fail in db_test.
Basically .. was being returned as a child of db/archive and ParseFileName returned false on that,
but 'type' was set to LogFile from earlier and not reset. The return of ParseFileName was not being checked to delete the log file or not.

Test Plan: make all check

Reviewers: dhruba, haobo, xjin, kailiu, nkg-

Reviewed By: nkg-

CC: leveldb

Differential Revision: https://reviews.facebook.net/D13413
main
Mayank Agarwal 11 years ago
parent 40a1e31fa5
commit a8b4a69de0
  1. 4
      db/db_impl.cc
  2. 4
      db/db_test.cc

@ -3308,8 +3308,8 @@ Status DestroyDB(const std::string& dbname, const Options& options) {
env->GetChildren(archivedir, &archiveFiles); env->GetChildren(archivedir, &archiveFiles);
// Delete archival files. // Delete archival files.
for (size_t i = 0; i < archiveFiles.size(); ++i) { for (size_t i = 0; i < archiveFiles.size(); ++i) {
ParseFileName(archiveFiles[i], &number, &type); if (ParseFileName(archiveFiles[i], &number, &type) &&
if (type == kLogFile) { type == kLogFile) {
Status del = env->DeleteFile(archivedir + "/" + archiveFiles[i]); Status del = env->DeleteFile(archivedir + "/" + archiveFiles[i]);
if (result.ok() && !del.ok()) { if (result.ok() && !del.ok()) {
result = del; result = del;

@ -257,7 +257,7 @@ class DBTest {
~DBTest() { ~DBTest() {
delete db_; delete db_;
DestroyDB(dbname_, Options()); ASSERT_OK(DestroyDB(dbname_, Options()));
delete env_; delete env_;
delete filter_policy_; delete filter_policy_;
} }
@ -378,7 +378,7 @@ class DBTest {
void Destroy(Options* options) { void Destroy(Options* options) {
delete db_; delete db_;
db_ = nullptr; db_ = nullptr;
DestroyDB(dbname_, *options); ASSERT_OK(DestroyDB(dbname_, *options));
} }
Status PureReopen(Options* options, DB** db) { Status PureReopen(Options* options, DB** db) {

Loading…
Cancel
Save