Retry preset migration when login warmup 401 blocks cloud check (#14049)

This commit is contained in:
ExPikaPaka
2026-06-05 15:25:45 +02:00
committed by GitHub
parent bf8397c0d4
commit 3ab9e0e923
2 changed files with 20 additions and 0 deletions

View File

@@ -6057,6 +6057,25 @@ bool GUI_App::maybe_migrate_user_presets_on_login()
if (ret != 0) {
BOOST_LOG_TRIVIAL(warning) << "Failed to query OrcaCloud presets (error " << ret
<< "), skipping migration to avoid overwriting cloud data.";
// If this looks like a transient 401 from token propagation delay (within grace period),
// schedule one deferred retry so first-time users don't silently lose their preset migration.
if (std::chrono::steady_clock::now() - m_last_401_error_time < std::chrono::seconds(30)
&& !m_migration_retry_pending.exchange(true)) {
BOOST_LOG_TRIVIAL(info) << "Scheduling migration retry after token propagation window.";
boost::thread([this]() {
std::this_thread::sleep_for(std::chrono::seconds(5));
CallAfter([this]() {
m_migration_retry_pending = false;
if (is_closing() || !m_agent || !m_agent->is_user_login()) return;
BOOST_LOG_TRIVIAL(info) << "Retrying preset migration after token propagation window.";
if (maybe_migrate_user_presets_on_login()) {
const std::string user_id = m_agent->get_user_id();
preset_bundle->load_user_presets(user_id, ForwardCompatibilitySubstitutionRule::Enable);
if (mainframe) mainframe->update_side_preset_ui();
}
});
}).detach();
}
return false;
}
BOOST_LOG_TRIVIAL(info) << "OrcaCloud has no presets for user " << new_user_id << ", proceeding with migration check.";

View File

@@ -324,6 +324,7 @@ private:
std::shared_ptr<int> m_user_sync_token;
std::atomic<bool> m_restart_sync_pending {false};
std::atomic<bool> m_sync_user_presets_now {false}; // request the sync loop to push user presets on its next tick
std::atomic<bool> m_migration_retry_pending {false};
bool m_is_dark_mode{ false };
bool m_adding_script_handler { false };
bool m_side_popup_status{false};