Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: fix appstream deprecations #1835

Merged
merged 6 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Core/FlatpakBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ public class AppCenterCore.FlatpakBackend : Backend, Object {
user_appstream_pool.set_flags (AppStream.PoolFlags.LOAD_OS_COLLECTION);
#else
user_appstream_pool.set_flags (AppStream.PoolFlags.READ_COLLECTION);
#endif
user_appstream_pool.set_cache_flags (AppStream.CacheFlags.NONE);
#endif

system_appstream_pool = new AppStream.Pool ();
#if HAS_APPSTREAM_0_15
system_appstream_pool.set_flags (AppStream.PoolFlags.LOAD_OS_COLLECTION);
#else
system_appstream_pool.set_flags (AppStream.PoolFlags.READ_COLLECTION);
#endif
system_appstream_pool.set_cache_flags (AppStream.CacheFlags.NONE);
#endif
package_list = new Gee.HashMap<string, Package> (null, null);

// Monitor the FlatpakInstallation for changes (e.g. adding/removing remotes)
Expand Down Expand Up @@ -796,8 +796,13 @@ public class AppCenterCore.FlatpakBackend : Backend, Object {
private void reload_appstream_pool () {
var new_package_list = new Gee.HashMap<string, Package> ();

#if HAS_APPSTREAM_0_15
user_appstream_pool.reset_extra_data_locations ();
user_appstream_pool.add_extra_data_location (user_metadata_path, AppStream.FormatStyle.METAINFO);
#else
user_appstream_pool.clear_metadata_locations ();
user_appstream_pool.add_metadata_location (user_metadata_path);
#endif

try {
debug ("Loading flatpak user pool");
Expand Down Expand Up @@ -826,8 +831,13 @@ public class AppCenterCore.FlatpakBackend : Backend, Object {
});
}

#if HAS_APPSTREAM_0_15
system_appstream_pool.reset_extra_data_locations ();
system_appstream_pool.add_extra_data_location (system_metadata_path, AppStream.FormatStyle.METAINFO);
#else
system_appstream_pool.clear_metadata_locations ();
system_appstream_pool.add_metadata_location (system_metadata_path);
#endif

try {
debug ("Loading flatpak system pool");
Expand Down
16 changes: 14 additions & 2 deletions src/Core/PackageKitBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,19 @@ public class AppCenterCore.PackageKitBackend : Backend, Object {
package_list = new Gee.HashMap<string, AppCenterCore.Package> (null, null);
appstream_pool = new AppStream.Pool ();

// Clear out the default set of metadata locations and only use the folder that gets populated
// with elementary's AppStream data.
#if HIDE_UPSTREAM_DISTRO_APPS
#if HAS_APPSTREAM_0_15
appstream_pool.reset_extra_data_locations ();
appstream_pool.add_extra_data_location ("/usr/share/app-info", AppStream.FormatStyle.METAINFO);
#else
// Only use a user cache, the system cache probably contains all the Ubuntu components
appstream_pool.set_cache_flags (AppStream.CacheFlags.USE_USER);

// Clear out the default set of metadata locations and only use the folder that gets populated
// with elementary's AppStream data.
appstream_pool.clear_metadata_locations ();
appstream_pool.add_metadata_location ("/usr/share/app-info");
#endif
#endif

// We don't want to show installed desktop files here
Expand Down Expand Up @@ -294,7 +299,14 @@ public class AppCenterCore.PackageKitBackend : Backend, Object {
component.set_id (id);
component.set_origin (Package.APPCENTER_PACKAGE_ORIGIN);

#if HAS_APPSTREAM_0_15
var components = new GenericArray<AppStream.Component> ();
components.add (component);

appstream_pool.add_components (components);
#else
appstream_pool.add_component (component);
#endif

var package = new AppCenterCore.Package (this, component);
package_list[id] = package;
Expand Down