|
|
@ -605,9 +605,23 @@ bool AppInit2(boost::thread_group& threadGroup) |
|
|
|
|
|
|
|
|
|
|
|
if (!bitdb.Open(GetDataDir())) |
|
|
|
if (!bitdb.Open(GetDataDir())) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// try moving the database env out of the way
|
|
|
|
|
|
|
|
boost::filesystem::path pathDatabase = GetDataDir() / "database"; |
|
|
|
|
|
|
|
boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%"PRI64d".bak", GetTime()); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
boost::filesystem::rename(pathDatabase, pathDatabaseBak); |
|
|
|
|
|
|
|
printf("Moved old %s to %s. Retrying.\n", pathDatabase.string().c_str(), pathDatabaseBak.string().c_str()); |
|
|
|
|
|
|
|
} catch(boost::filesystem::filesystem_error &error) { |
|
|
|
|
|
|
|
// failure is ok (well, not really, but it's not worse than what we started with)
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// try again
|
|
|
|
|
|
|
|
if (!bitdb.Open(GetDataDir())) { |
|
|
|
|
|
|
|
// if it still fails, it probably means we can't even create the database env
|
|
|
|
string msg = strprintf(_("Error initializing wallet database environment %s!"), strDataDir.c_str()); |
|
|
|
string msg = strprintf(_("Error initializing wallet database environment %s!"), strDataDir.c_str()); |
|
|
|
return InitError(msg); |
|
|
|
return InitError(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (GetBoolArg("-salvagewallet")) |
|
|
|
if (GetBoolArg("-salvagewallet")) |
|
|
|
{ |
|
|
|
{ |
|
|
|