Skip to content

Commit

Permalink
Update - Better API
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Dec 25, 2023
1 parent 0ca624e commit 1569941
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions include/update/updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ namespace Nickvision::Aura::Update
* @return The current preview version if available, else empty Version
*/
Version fetchCurrentPreviewVersion();
#ifdef _WIN32
/**
* @brief Downloads and installs an application update for Windows. getCurrentStableVersion or getCurrentPreviewVersion should be called first before running this method. This method will force quit the current running application to install the update.
* @param versionType The type of version update to install
* @return True if successful, else false
*/
bool windowsUpdate(VersionType versionType);
#endif

private:
mutable std::mutex m_mutex;
Expand Down
8 changes: 4 additions & 4 deletions src/update/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ namespace Nickvision::Aura::Update
return fetchCurrentVersion(VersionType::Preview);
}

#ifdef _WIN32
bool Updater::windowsUpdate(VersionType versionType)
{
std::lock_guard<std::mutex> lock{ m_mutex };
#ifdef _WIN32
if (versionType == VersionType::Stable ? m_latestStableReleaseId == -1 : m_latestPreviewReleaseId == -1)
{
return false;
Expand Down Expand Up @@ -80,9 +80,9 @@ namespace Nickvision::Aura::Update
}
}
}
#endif
return false;
}
#endif

Version Updater::fetchCurrentVersion(VersionType versionType)
{
Expand All @@ -96,8 +96,8 @@ namespace Nickvision::Aura::Update
{
for (const Json::Value& release : root)
{
std::string version{ release.get("tag_name", "0.0.0").asString() };
if (version == "0.0.0")
std::string version{ release.get("tag_name", "NULL").asString() };
if (version == "NULL")
{
return {};
}
Expand Down

0 comments on commit 1569941

Please sign in to comment.