Force update if never updated

This commit is contained in:
fed 2023-06-15 01:19:30 +02:00
parent e26c990fab
commit 9a981f9173
4 changed files with 23 additions and 10 deletions

View File

@ -444,6 +444,7 @@ namespace ui_scripting
updater_table["getupdatedownloadstatus"] = updater::get_update_download_status; updater_table["getupdatedownloadstatus"] = updater::get_update_download_status;
updater_table["cancelupdate"] = updater::cancel_update; updater_table["cancelupdate"] = updater::cancel_update;
updater_table["isrestartrequired"] = updater::is_restart_required; updater_table["isrestartrequired"] = updater::is_restart_required;
updater_table["shouldforceupdate"] = updater::should_force_update;
updater_table["getlasterror"] = updater::get_last_error; updater_table["getlasterror"] = updater::get_last_error;
updater_table["getcurrentfile"] = updater::get_current_file; updater_table["getcurrentfile"] = updater::get_current_file;

View File

@ -568,6 +568,12 @@ namespace updater
}, scheduler::pipeline::async); }, scheduler::pipeline::async);
} }
bool should_force_update()
{
const auto folder = (utils::properties::get_appdata_path() / CLIENT_DATA_FOLDER).generic_string();
return !utils::io::directory_exists(folder) || utils::io::directory_is_empty(folder);
}
class component final : public component_interface class component final : public component_interface
{ {
public: public:

View File

@ -25,4 +25,6 @@ namespace updater
void start_update_check(); void start_update_check();
void start_update_download(); void start_update_download();
void cancel_update(); void cancel_update();
bool should_force_update();
} }

View File

@ -31,17 +31,21 @@ function startupdatecheck(popup, autoclose)
return return
end end
LUI.yesnopopup({ if (updater.shouldforceupdate()) then
title = Engine.Localize("@MENU_NOTICE"), startupdatedownload(popup, autoclose)
text = Engine.Localize("@MENU_CCS_NEW_PATCH_NOTICE") .. " " .. Engine.Localize("@MENU_DOWNLOAD_AUTOUPDATE_PATCH"), else
callback = function(result) LUI.yesnopopup({
if (result) then title = Engine.Localize("@MENU_NOTICE"),
startupdatedownload(popup, autoclose) text = Engine.Localize("@MENU_CCS_NEW_PATCH_NOTICE") .. " " .. Engine.Localize("@MENU_DOWNLOAD_AUTOUPDATE_PATCH"),
else callback = function(result)
LUI.FlowManager.RequestLeaveMenu(popup) if (result) then
startupdatedownload(popup, autoclose)
else
LUI.FlowManager.RequestLeaveMenu(popup)
end
end end
end })
}) end
end) end)
updater.startupdatecheck() updater.startupdatecheck()