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
This commit is contained in:
Mayank Agarwal 2013-10-10 18:02:10 -07:00
parent 40a1e31fa5
commit a8b4a69de0
2 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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) {