From 501f616717587389bb79eae2c976baa305a04ba9 Mon Sep 17 00:00:00 2001 From: Zarg <62082797+Zaarrg@users.noreply.github.com> Date: Mon, 14 Apr 2025 23:40:05 +0200 Subject: [PATCH] Added check for stremio service - Check for stremio service to use server.js of stremio service --- .idea/discord.xml | 7 +++++++ .idea/modules.xml | 8 ++++++++ build/deploy_windows.js | 2 +- src/node/server.cpp | 29 ++++++++++++++++++++++------- 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 .idea/discord.xml create mode 100644 .idea/modules.xml diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..30bab2a --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..26d7415 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/build/deploy_windows.js b/build/deploy_windows.js index b991e35..02b9984 100644 --- a/build/deploy_windows.js +++ b/build/deploy_windows.js @@ -55,7 +55,7 @@ const VCPKG_CMAKE = 'C:/bin/vcpkg/scripts/buildsystems/vcpkg.cmake'; fs.mkdirSync(BUILD_DIR, { recursive: true }); } - console.log('\n=== Running CMake in cmake-build-release ==='); + console.log(`\n=== Running CMake in cmake-build-${debugBuild ? "Debug" : "Release"} ===`); process.chdir(BUILD_DIR); execSync( `cmake -G Ninja -DCMAKE_BUILD_TYPE=${debugBuild ? "Debug" : "Release"} -DCMAKE_TOOLCHAIN_FILE=${VCPKG_CMAKE} -DVCPKG_TARGET_TRIPLET=${VCPKG_TRIPLET} ..`, diff --git a/src/node/server.cpp b/src/node/server.cpp index 12ada12..f178897 100644 --- a/src/node/server.cpp +++ b/src/node/server.cpp @@ -1,5 +1,6 @@ #include "server.h" #include +#include #include #include #include @@ -27,13 +28,27 @@ bool StartNodeServer() std::wstring exeDir = GetExeDirectory(); std::wstring exePath = exeDir + L"\\stremio-runtime.exe"; std::wstring scriptPath = exeDir + L"\\server.js"; - if(!FileExists(exePath)){ - AppendToCrashLog(L"[NODE]: Missing stremio-runtime.exe"); - return false; - } - if(!FileExists(scriptPath)){ - AppendToCrashLog(L"[NODE]: Missing server.js"); - return false; + + if (!FileExists(exePath) || !FileExists(scriptPath)) { + // Check alternative path in %localappdata% + wchar_t localAppData[MAX_PATH]; + if (SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, localAppData))) { + std::wstring altDir = std::wstring(localAppData) + L"\\Programs\\StremioService"; + std::wstring altExePath = altDir + L"\\stremio-runtime.exe"; + std::wstring altScriptPath = altDir + L"\\server.js"; + + if (FileExists(altExePath) && FileExists(altScriptPath)) { + exePath = altExePath; + scriptPath = altScriptPath; + exeDir = altDir; + } else { + AppendToCrashLog(L"[NODE]: Missing stremio-runtime.exe and server.js in both exeDir and localappdata."); + return false; + } + } else { + AppendToCrashLog(L"[NODE]: Failed to retrieve local app data path."); + return false; + } } if (!g_serverJob) {