Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/backends/FlatpakBackend/FlatpakBackend.cpp
Show First 20 Lines • Show All 498 Lines • ▼ Show 20 Line(s) | 497 | { | |||
---|---|---|---|---|---|
499 | 499 | | |||
500 | GPtrArray *remotes = flatpak_installation_list_remotes(flatpakInstallation, m_cancellable, nullptr); | 500 | GPtrArray *remotes = flatpak_installation_list_remotes(flatpakInstallation, m_cancellable, nullptr); | ||
501 | if (!remotes) { | 501 | if (!remotes) { | ||
502 | return false; | 502 | return false; | ||
503 | } | 503 | } | ||
504 | 504 | | |||
505 | for (uint i = 0; i < remotes->len; i++) { | 505 | for (uint i = 0; i < remotes->len; i++) { | ||
506 | FlatpakRemote *remote = FLATPAK_REMOTE(g_ptr_array_index(remotes, i)); | 506 | FlatpakRemote *remote = FLATPAK_REMOTE(g_ptr_array_index(remotes, i)); | ||
507 | g_autoptr(GFile) fileTimestamp = flatpak_remote_get_appstream_timestamp(remote, nullptr); | ||||
apol: Can you declare and set in the same line? No need to set it to null first. | |||||
507 | 508 | | |||
508 | // Refresh appstream metadata first, otherwise we won't be able to list new application or any application | 509 | QFileInfo fileInfo = QFileInfo(QString::fromUtf8(g_file_get_path(fileTimestamp))); | ||
509 | // at all for newly added repository | 510 | // Refresh appstream metadata in case they have never been refreshed or the cache is older than 6 hours | ||
511 | if (!fileInfo.exists() || fileInfo.lastModified().toUTC().secsTo(QDateTime::currentDateTimeUtc()) > 21600) { | ||||
510 | refreshAppstreamMetadata(flatpakInstallation, remote); | 512 | refreshAppstreamMetadata(flatpakInstallation, remote); | ||
513 | } else { | ||||
514 | integrateRemote(flatpakInstallation, remote); | ||||
515 | } | ||||
511 | } | 516 | } | ||
512 | 517 | | |||
513 | return true; | 518 | return true; | ||
514 | } | 519 | } | ||
515 | 520 | | |||
516 | void FlatpakBackend::integrateRemote(FlatpakInstallation *flatpakInstallation, FlatpakRemote *remote) | 521 | void FlatpakBackend::integrateRemote(FlatpakInstallation *flatpakInstallation, FlatpakRemote *remote) | ||
517 | { | 522 | { | ||
518 | FlatpakSource source(remote); | 523 | FlatpakSource source(remote); | ||
▲ Show 20 Lines • Show All 642 Lines • Show Last 20 Lines |
Can you declare and set in the same line? No need to set it to null first.