mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix deletion of orphan nodestore directories:
Orphaned nodestore directories should only be deleted if the proper nodestore directories are confirmed to exist.
This commit is contained in:
committed by
Nik Bougalis
parent
c2a08a1f26
commit
06e87e0f6a
@@ -485,6 +485,7 @@ SHAMapStoreImp::dbPaths()
|
|||||||
bool writableDbExists = false;
|
bool writableDbExists = false;
|
||||||
bool archiveDbExists = false;
|
bool archiveDbExists = false;
|
||||||
|
|
||||||
|
std::vector<boost::filesystem::path> pathsToDelete;
|
||||||
for (boost::filesystem::directory_iterator it(dbPath);
|
for (boost::filesystem::directory_iterator it(dbPath);
|
||||||
it != boost::filesystem::directory_iterator();
|
it != boost::filesystem::directory_iterator();
|
||||||
++it)
|
++it)
|
||||||
@@ -494,7 +495,7 @@ SHAMapStoreImp::dbPaths()
|
|||||||
else if (!state.archiveDb.compare(it->path().string()))
|
else if (!state.archiveDb.compare(it->path().string()))
|
||||||
archiveDbExists = true;
|
archiveDbExists = true;
|
||||||
else if (!dbPrefix_.compare(it->path().stem().string()))
|
else if (!dbPrefix_.compare(it->path().stem().string()))
|
||||||
boost::filesystem::remove_all(it->path());
|
pathsToDelete.push_back(it->path());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!writableDbExists && state.writableDb.size()) ||
|
if ((!writableDbExists && state.writableDb.size()) ||
|
||||||
@@ -524,6 +525,10 @@ SHAMapStoreImp::dbPaths()
|
|||||||
|
|
||||||
Throw<std::runtime_error>("state db error");
|
Throw<std::runtime_error>("state db error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The necessary directories exist. Now, remove any others.
|
||||||
|
for (boost::filesystem::path& p : pathsToDelete)
|
||||||
|
boost::filesystem::remove_all(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<NodeStore::Backend>
|
std::unique_ptr<NodeStore::Backend>
|
||||||
|
|||||||
Reference in New Issue
Block a user