1616#include < log/log.h>
1717
1818#include < service/database/database.h>
19- #include < service/external/github.h>
20- #include < service/storage/realtime.h>
21- #include < service/system/lang.h>
2219#include < service/external/crowdin.h>
2320#include < service/external/frontend.h>
21+ #include < service/external/github.h>
22+ #include < service/project/virtual/virtual.h>
23+ #include < service/storage/ingestor/recipe/recipe_builtin.h>
24+ #include < service/storage/realtime.h>
2425#include < service/system/access_keys.h>
2526#include < service/system/game_data.h>
26- #include < service/storage/ingestor/recipe/recipe_builtin.h>
27- #include < service/project/virtual/virtual.h>
27+ #include < service/system/lang.h>
2828#include < service/system/startup.h>
2929
3030using namespace drogon ;
3131using namespace logging ;
3232using namespace service ;
33+ namespace fs = std::filesystem;
3334
3435namespace service {
3536 trantor::EventLoopThreadPool cacheAwaiterThreadPool{10 };
@@ -65,11 +66,11 @@ void globalExceptionHandler(const std::exception &e, const HttpRequestPtr &req,
6566 callback (statusResponse (k500InternalServerError));
6667}
6768
68- Task<> runStartupTaks () {
69- global::virtualProject = co_await createVirtualProject ();
69+ Task<> runStartupTaks (const fs::path gameFilesPath ) {
70+ global::virtualProject = co_await createVirtualProject (gameFilesPath );
7071
7172 co_await cleanupLoadingDeployments ();
72- co_await global::gameData->setupGameData ( );
73+ co_await global::gameData->importGameData ( false );
7374 co_await global::crowdin->getAvailableLocales ();
7475}
7576
@@ -82,13 +83,16 @@ int main() {
8283 app ().setLogLevel (level).addListener (" 0.0.0.0" , port).setThreadNum (16 );
8384 configureLoggingLevel ();
8485
85- const auto [authConfig, githubAppConfig, mrApp, crowdinConfig, sentryConfig, appUrl, curseForgeKey, storagePath,
86- salt, local] = config::configure ();
86+ const auto [authConfig, githubAppConfig, mrApp, crowdinConfig, sentryConfig, appUrl, curseForgeKey, storagePath, salt, local] =
87+ config::configure ();
8788
8889 if (!sentryConfig.dsn .empty ()) {
8990 monitor::initSentry (sentryConfig.dsn );
9091 }
9192
93+ const auto gameFilesPath = fs::path (storagePath) / " .game" ;
94+ fs::create_directories (gameFilesPath);
95+
9296 global::database = std::make_shared<Database>();
9397 global::cache = std::make_shared<MemoryCache>();
9498 global::github = std::make_shared<GitHub>();
@@ -97,7 +101,7 @@ int main() {
97101 global::auth = std::make_shared<Auth>(appUrl, OAuthApp{githubAppConfig.clientId , githubAppConfig.clientSecret },
98102 OAuthApp{mrApp.clientId , mrApp.clientSecret });
99103 global::lang = std::make_shared<LangService>();
100- global::gameData = std::make_shared<GameDataService>(storagePath );
104+ global::gameData = std::make_shared<GameDataService>();
101105 global::crowdin = std::make_shared<Crowdin>(crowdinConfig);
102106 global::accessKeys = std::make_shared<AccessKeys>(salt);
103107 global::frontend = std::make_shared<FrontendService>(authConfig.frontendUrl , authConfig.frontendApiKey );
@@ -131,7 +135,7 @@ int main() {
131135
132136 content::loadBuiltinRecipeTypes ();
133137
134- app ().getLoop ()->queueInLoop (async_func ([]() -> Task<> { co_await runStartupTaks (); }));
138+ app ().getLoop ()->queueInLoop (async_func ([= ]() -> Task<> { co_await runStartupTaks (gameFilesPath ); }));
135139
136140 app ().run ();
137141
0 commit comments