MCPcopy Create free account
hub / github.com/DistroAV/DistroAV / updateCheckStart

Function updateCheckStart

src/forms/update.cpp:428–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426}
427
428bool updateCheckStart(UserRequestCallback userRequestCallback)
429{
430 auto methodSignature =
431 QString("updateCheckStart(userRequestCallback=%1)").arg(userRequestCallback ? "..." : "nullptr");
432 obs_log(LOG_DEBUG, "+%s", QT_TO_UTF8(methodSignature));
433
434 auto isAutoCheck = userRequestCallback == nullptr;
435
436 auto config = Config::Current();
437 if (isAutoCheck && !config->AutoCheckForUpdates()) {
438 obs_log(LOG_DEBUG, "updateCheckStart: AutoCheckForUpdates is disabled; ignoring");
439 obs_log(LOG_DEBUG, "-%s", QT_TO_UTF8(methodSignature));
440 return false;
441 }
442
443 if (isUpdatePendingOrShowing()) {
444 if (update_dialog) {
445 update_dialog->raise();
446 }
447 obs_log(LOG_DEBUG, "updateCheckStart: update pending or showing; ignoring");
448 obs_log(LOG_DEBUG, "-%s", QT_TO_UTF8(methodSignature));
449 return false;
450 }
451
452 //
453 // Avoid hitting the server too often by limiting auto-checks to every minAutoUpdateCheckIntervalSeconds.
454 //
455 if (isAutoCheck && !Config::UpdateLastCheckIgnore) {
456 auto now = QDateTime::currentDateTime();
457
458 auto minAutoUpdateCheckIntervalSeconds = config->MinAutoUpdateCheckIntervalSeconds();
459 if (minAutoUpdateCheckIntervalSeconds > 0) {
460 auto lastUpdateCheck = config->LastUpdateCheck();
461 auto elapsedSeconds = lastUpdateCheck.secsTo(now);
462 if (elapsedSeconds < minAutoUpdateCheckIntervalSeconds) {
463 obs_log(LOG_DEBUG,
464 "updateCheckStart: elapsedSeconds=%lld < minAutoUpdateCheckIntervalSeconds=%d; ignoring",
465 elapsedSeconds, minAutoUpdateCheckIntervalSeconds);
466 obs_log(LOG_DEBUG, "-%s", QT_TO_UTF8(methodSignature));
467 return false;
468 }
469 }
470 }
471 config->LastUpdateCheck(QDateTime::currentDateTime());
472
473 auto main_window = static_cast<QMainWindow *>(obs_frontend_get_main_window());
474
475//#define DIRECT_REQUEST_GITHUB
476#ifdef DIRECT_REQUEST_GITHUB
477 // Used to test directly hitting github instead of going through distroav.org firebase hosting+functions.
478 QUrl url("https://api.github.com/repos/DistroAV/DistroAV/releases/latest");
479#else
480 QUrl url(rehostUrl(PLUGIN_UPDATE_URL));
481 obs_log(LOG_DEBUG, "updateCheckStart: url='%s'", QT_TO_UTF8(url.toString()));
482
483 auto pluginVersion = QString(PLUGIN_VERSION);
484 auto obsGuid = config->GetInstallGUID();
485

Callers 2

obs_module_post_loadFunction · 0.85
OutputSettingsMethod · 0.85

Calls 9

isUpdatePendingOrShowingFunction · 0.85
rehostUrlFunction · 0.85
updateCheckStopFunction · 0.85
AutoCheckForUpdatesMethod · 0.80
LastUpdateCheckMethod · 0.80
GetInstallGUIDMethod · 0.80

Tested by

no test coverage detected