Skip to content

Commit

Permalink
fix(Remote): Return is version info is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
Yimura committed Feb 23, 2022
1 parent 1c11971 commit 19d9b21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Remote.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Remote
const std::string m_Path;
const std::string m_Version;
const int m_VersionMachine;
const bool m_Valid;
};

inline VersionInfo GetVersionInfo(const std::string_view dllProvider)
Expand All @@ -22,7 +23,7 @@ namespace Remote

nlohmann::json j = nlohmann::json::parse(res.body.begin(), res.body.end());

return { j["file"], j["version"], j["version_machine"] };
return { j["file"], j["version"], j["version_machine"], true };
}
catch (const std::exception&)
{
Expand Down
7 changes: 7 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ int main(int argc, const char** argv)
dllFile = g.m_WebServer.m_File;

const auto versionInfo = Remote::GetVersionInfo(g.m_WebServer.m_DllProvider);
if (!versionInfo.m_Valid)
{
LOG(WARNING) << "Host did not return valid version data, does it have a version.json?";

return 1;
}

if (!std::filesystem::exists(dllFile) || g.m_WebServer.m_VersionMachine < versionInfo.m_VersionMachine)
{
if (!Remote::DownloadBinary(
Expand Down

0 comments on commit 19d9b21

Please sign in to comment.