mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 11:15:56 +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 archiveDbExists = false;
|
||||
|
||||
std::vector<boost::filesystem::path> pathsToDelete;
|
||||
for (boost::filesystem::directory_iterator it(dbPath);
|
||||
it != boost::filesystem::directory_iterator();
|
||||
++it)
|
||||
@@ -494,7 +495,7 @@ SHAMapStoreImp::dbPaths()
|
||||
else if (!state.archiveDb.compare(it->path().string()))
|
||||
archiveDbExists = true;
|
||||
else if (!dbPrefix_.compare(it->path().stem().string()))
|
||||
boost::filesystem::remove_all(it->path());
|
||||
pathsToDelete.push_back(it->path());
|
||||
}
|
||||
|
||||
if ((!writableDbExists && state.writableDb.size()) ||
|
||||
@@ -524,6 +525,10 @@ SHAMapStoreImp::dbPaths()
|
||||
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user