mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-24 07:38:15 -05:00
Currently flatpak_installation_fetch_remote_ref_sync() does not work offline. It returns an error when it fails to fetch the remote's summary in flatpak_dir_get_remote_state(). This is a problem since GNOME Software (or at least the Endless fork) uses this library function to display apps it finds on a USB drive (see gs_plugin_refine_item_origin() in gs-flatpak.c) and that's something that should work even offline. So this commit changes flatpak_dir_get_remote_state_optional() so that it accepts the only_cached option, and updates the call sites. Also have fetch_remote_ref_sync() use flatpak_dir_get_remote_state_optional(), which means that when we're offline we will use the xa.cache data in the ostree-metadata ref as a list of refs list instead of using a summary. However since the commit checksums are not in xa.cache, we don't have enough information to form a FlatpakRemoteRef. So also call ostree_repo_find_remotes_async() to get the commit from any LAN or USB sources that may be available. This may not be very performant but at least it only happens if the ref wasn't found in a remote summary; see https://github.com/flatpak/flatpak/issues/1862 It's sad this code is so long-winded but it's difficult to break out a helper function that could be shared with list_remotes_for_configured_remote() above. Longer term we could improve the ostree_repo_find_remotes_async() API and add options to remove the need to manually handle OstreeRepoFinder objects. Closes: #3114 Approved by: alexlarsson