Make failure to checkpoint WAL non-fatal, make sure that early logs are not swallowed.

This commit is contained in:
Christian Speckner 2019-05-04 20:37:14 +02:00
parent cc5db6b330
commit ca96f20bc2
3 changed files with 19 additions and 3 deletions

View File

@ -75,10 +75,22 @@ void SqliteDatabase::initialize()
throw SqliteError("unable to initialize sqlite DB for unknown reason");
};
Logger::log("successfully opened " + myDatabaseFile, 2);
exec("PRAGMA journal_mode=WAL");
if (sqlite3_wal_checkpoint_v2(myHandle, nullptr, SQLITE_CHECKPOINT_TRUNCATE, nullptr, nullptr) != SQLITE_OK)
throw SqliteError(sqlite3_errmsg(myHandle));
switch (sqlite3_wal_checkpoint_v2(myHandle, nullptr, SQLITE_CHECKPOINT_TRUNCATE, nullptr, nullptr)) {
case SQLITE_OK:
break;
case SQLITE_MISUSE:
Logger::log("failed to checkpoint WAL on " + myDatabaseFile + " - WAL probably unavailable", 1);
break;
default:
Logger::log("failed to checkpoint WAL on " + myDatabaseFile + " : " + sqlite3_errmsg(myHandle), 1);
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -77,6 +77,7 @@ namespace {
OSystem::OSystem()
: myLauncherUsed(false),
myQuitLoop(false),
mySettingsLoaded(false),
myFpsMeter(FPS_METER_QUEUE_SIZE)
{
// Get built-in features
@ -224,6 +225,7 @@ void OSystem::loadConfig(const Settings::Options& options)
Logger::log("Loading config options ...", 2);
mySettings->load(options);
mySettingsLoaded = true;
myPropSet->load(myPropertiesFile);
}
@ -492,7 +494,7 @@ void OSystem::logMessage(const string& message, uInt8 level)
cout << message << endl << std::flush;
myLogMessages += message + "\n";
}
else if(level <= uInt8(mySettings->getInt("loglevel")))
else if(level <= uInt8(mySettings->getInt("loglevel")) || !mySettingsLoaded)
{
if(mySettings->getBool("logtoconsole"))
cout << message << endl << std::flush;

View File

@ -537,6 +537,8 @@ class OSystem
string myDefaultSaveDir;
string myDefaultLoadDir;
bool mySettingsLoaded;
string myCheatFile;
string myConfigFile;
string myPaletteFile;