Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 1,057 Lines • ▼ Show 20 Lines | static void CleanupBlockRevFiles() { | ||||
// Glob all blk?????.dat and rev?????.dat files from the blocks directory. | // Glob all blk?????.dat and rev?????.dat files from the blocks directory. | ||||
// Remove the rev files immediately and insert the blk file paths into an | // Remove the rev files immediately and insert the blk file paths into an | ||||
// ordered map keyed by block file index. | // ordered map keyed by block file index. | ||||
LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for " | LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for " | ||||
"-reindex with -prune\n"); | "-reindex with -prune\n"); | ||||
fs::path blocksdir = GetBlocksDir(); | fs::path blocksdir = GetBlocksDir(); | ||||
for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); | for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); | ||||
it++) { | it++) { | ||||
if (is_regular_file(*it) && | if (fs::is_regular_file(*it) && | ||||
it->path().filename().string().length() == 12 && | it->path().filename().string().length() == 12 && | ||||
it->path().filename().string().substr(8, 4) == ".dat") { | it->path().filename().string().substr(8, 4) == ".dat") { | ||||
if (it->path().filename().string().substr(0, 3) == "blk") { | if (it->path().filename().string().substr(0, 3) == "blk") { | ||||
mapBlockFiles[it->path().filename().string().substr(3, 5)] = | mapBlockFiles[it->path().filename().string().substr(3, 5)] = | ||||
it->path(); | it->path(); | ||||
} else if (it->path().filename().string().substr(0, 3) == "rev") { | } else if (it->path().filename().string().substr(0, 3) == "rev") { | ||||
remove(it->path()); | remove(it->path()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,386 Lines • Show Last 20 Lines |