File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -605,8 +605,22 @@ bool AppInit2(boost::thread_group& threadGroup)
605605
606606 if (!bitdb.Open (GetDataDir ()))
607607 {
608- string msg = strprintf (_ (" Error initializing wallet database environment %s!" ), strDataDir.c_str ());
609- return InitError (msg);
608+ // try moving the database env out of the way
609+ boost::filesystem::path pathDatabase = GetDataDir () / " database" ;
610+ boost::filesystem::path pathDatabaseBak = GetDataDir () / strprintf (" database.%" PRI64d" .bak" , GetTime ());
611+ try {
612+ boost::filesystem::rename (pathDatabase, pathDatabaseBak);
613+ printf (" Moved old %s to %s. Retrying.\n " , pathDatabase.string ().c_str (), pathDatabaseBak.string ().c_str ());
614+ } catch (boost::filesystem::filesystem_error &error) {
615+ // failure is ok (well, not really, but it's not worse than what we started with)
616+ }
617+
618+ // try again
619+ if (!bitdb.Open (GetDataDir ())) {
620+ // if it still fails, it probably means we can't even create the database env
621+ string msg = strprintf (_ (" Error initializing wallet database environment %s!" ), strDataDir.c_str ());
622+ return InitError (msg);
623+ }
610624 }
611625
612626 if (GetBoolArg (" -salvagewallet" ))
You can’t perform that action at this time.
0 commit comments