lmdb: Fix storage initialization when config file cannot be loaded
This commit is contained in:
parent
26f787fb42
commit
1c820fc2f6
|
@ -218,7 +218,7 @@ std::vector<std::shared_ptr<BuildAction>> ServiceSetup::BuildSetup::getBuildActi
|
|||
return buildActions;
|
||||
}
|
||||
|
||||
void ServiceSetup::loadConfigFiles(bool restoreStateAndDiscardDatabases)
|
||||
void ServiceSetup::loadConfigFiles(bool doFirstTimeSetup)
|
||||
{
|
||||
// read config file
|
||||
cout << Phrases::InfoMessage << "Reading config file: " << configFilePath << Phrases::EndFlush;
|
||||
|
@ -264,11 +264,9 @@ void ServiceSetup::loadConfigFiles(bool restoreStateAndDiscardDatabases)
|
|||
}
|
||||
}
|
||||
// restore state/cache and discard databases
|
||||
if (restoreStateAndDiscardDatabases) {
|
||||
restoreState();
|
||||
config.initStorage(dbPath.data(), maxDbs);
|
||||
config.markAllDatabasesToBeDiscarded();
|
||||
restoreStateAndDiscardDatabases = false;
|
||||
if (doFirstTimeSetup) {
|
||||
initStorage();
|
||||
doFirstTimeSetup = false;
|
||||
}
|
||||
// read webserver, build and user configuration (partially cached so read it after the cache has been restored to override cached values)
|
||||
for (const auto &iniEntry : configIni.data()) {
|
||||
|
@ -288,9 +286,8 @@ void ServiceSetup::loadConfigFiles(bool restoreStateAndDiscardDatabases)
|
|||
}
|
||||
|
||||
// restore state/cache and discard databases if not done yet
|
||||
if (restoreStateAndDiscardDatabases) {
|
||||
restoreState();
|
||||
config.markAllDatabasesToBeDiscarded();
|
||||
if (doFirstTimeSetup) {
|
||||
initStorage();
|
||||
}
|
||||
|
||||
// read pacman config
|
||||
|
@ -622,6 +619,14 @@ std::size_t ServiceSetup::saveState()
|
|||
return size;
|
||||
}
|
||||
|
||||
void ServiceSetup::initStorage()
|
||||
{
|
||||
cout << Phrases::InfoMessage << "Opening LMDB file: " << dbPath << " (max DBs: " << maxDbs << ')' << Phrases::EndFlush;
|
||||
config.initStorage(dbPath.data(), maxDbs);
|
||||
restoreState();
|
||||
config.markAllDatabasesToBeDiscarded();
|
||||
}
|
||||
|
||||
void ServiceSetup::run()
|
||||
{
|
||||
#ifndef CPP_UTILITIES_DEBUG_BUILD
|
||||
|
|
|
@ -144,13 +144,14 @@ struct LIBREPOMGR_EXPORT ServiceSetup : public LibPkg::Lockable {
|
|||
LockTable m_locksByName;
|
||||
} locks;
|
||||
|
||||
void loadConfigFiles(bool restoreStateAndDiscardDatabases);
|
||||
void loadConfigFiles(bool doFirstTimeSetup);
|
||||
void printDatabases();
|
||||
std::string_view cacheFilePath() const;
|
||||
RAPIDJSON_NAMESPACE::Document libraryDependenciesToJson();
|
||||
void restoreLibraryDependenciesFromJson(const std::string &json, ReflectiveRapidJSON::JsonDeserializationErrors *errors);
|
||||
std::size_t restoreState();
|
||||
std::size_t saveState();
|
||||
void initStorage();
|
||||
void run();
|
||||
ServiceStatus computeStatus() const;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue