From a8b4a69de099f2c1bd097f37daf7ad9ba816e2ae Mon Sep 17 00:00:00 2001 From: Mayank Agarwal Date: Thu, 10 Oct 2013 18:02:10 -0700 Subject: [PATCH] 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 --- db/db_impl.cc | 4 ++-- db/db_test.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 3e4984d97..57d5916b7 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -3308,8 +3308,8 @@ Status DestroyDB(const std::string& dbname, const Options& options) { env->GetChildren(archivedir, &archiveFiles); // Delete archival files. for (size_t i = 0; i < archiveFiles.size(); ++i) { - ParseFileName(archiveFiles[i], &number, &type); - if (type == kLogFile) { + if (ParseFileName(archiveFiles[i], &number, &type) && + type == kLogFile) { Status del = env->DeleteFile(archivedir + "/" + archiveFiles[i]); if (result.ok() && !del.ok()) { result = del; diff --git a/db/db_test.cc b/db/db_test.cc index d69280e8a..d0dc26146 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -257,7 +257,7 @@ class DBTest { ~DBTest() { delete db_; - DestroyDB(dbname_, Options()); + ASSERT_OK(DestroyDB(dbname_, Options())); delete env_; delete filter_policy_; } @@ -378,7 +378,7 @@ class DBTest { void Destroy(Options* options) { delete db_; db_ = nullptr; - DestroyDB(dbname_, *options); + ASSERT_OK(DestroyDB(dbname_, *options)); } Status PureReopen(Options* options, DB** db) { -- GitLab