mirror of
https://github.com/flatpak/flatpak.git
synced 2026-02-06 22:11:32 -05:00
When Flatpak is fetching a locale extension it has to decide which subpaths to fetch based on what language is being used on the computer. This happens in flatpak_dir_get_locale_subpaths() which indirectly uses the org.freedesktop.Accounts D-Bus object to check what language is configured for each user. The problem is that if any user doesn't have a language set, Flatpak falls back to pulling all languages, rather than checking the system default using localed. The effect is that on Endless OS systems, Flatpak is pulling entire locale extensions rather than just the subset for the configured language, which is a significant waste of bandwidth. In my testing, the "Language" property on the primary user account is not set on Endless, but it is set on Fedora. A side effect of this bug is to cause offline USB app installs to sometimes fail, because if the USB only has a partial locale and you try to pull the whole thing, the pull fails. This commit fixes the issue by doing another D-Bus call to localed to get the system default(s), then checking AccountsService as before, treating an unset language for a user account as meaning "use the system default". Then only if no languages are set for the users or the system, fall back to pulling all languages. The code to communicate with localed is based on the code in gnome-control-center in panels/region/cc-region-panel.c This extra synchronous D-Bus call adds some overhead which might be able to be avoided; see https://github.com/flatpak/flatpak/issues/1938 Using this patch I can see that Flatpak is pulling partial locales now, based on the output of `flatpak list -a | grep partial` after installing Bijiben from Flathub. Closes: #1937 Approved by: alexlarsson