summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-10-12 10:16:11 +0100
committerRichard Hughes <richard@hughsie.com>2016-10-12 10:16:33 +0100
commit6c3ec7e6e2958296cb9f05fd8e701e0fc13211cf (patch)
tree7a8f9193bfa3310ca907400a0fe6ed3625c0f5f3
parent65c520ed1d141df1b0cbca153f62820f989fdfa3 (diff)
downloadappstream-glib-6c3ec7e6e2958296cb9f05fd8e701e0fc13211cf.tar.gz
Add flag to only load uncompressed files into a store
Sometimes we just want the 'extra' files rather than the distro-supplied ones.
-rw-r--r--libappstream-glib/as-store.c8
-rw-r--r--libappstream-glib/as-store.h23
2 files changed, 21 insertions, 10 deletions
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index 44f15ed..c7fdf5d 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -2387,12 +2387,20 @@ as_store_load_app_info_file (AsStore *store,
AsAppScope scope,
const gchar *path_xml,
const gchar *arch,
+ AsStoreLoadFlags flags,
GCancellable *cancellable,
GError **error)
{
AsStorePrivate *priv = GET_PRIVATE (store);
g_autoptr(GFile) file = NULL;
+ /* ignore large compressed files */
+ if (flags & AS_STORE_LOAD_FLAG_ONLY_UNCOMPRESSED &&
+ g_str_has_suffix (path_xml, ".gz")) {
+ g_debug ("ignoring compressed file %s", path_xml);
+ return TRUE;
+ }
+
/* guess this based on the name */
if (!as_store_guess_origin_fallback (store, path_xml, error))
return FALSE;
diff --git a/libappstream-glib/as-store.h b/libappstream-glib/as-store.h
index b09169a..c35ca40 100644
--- a/libappstream-glib/as-store.h
+++ b/libappstream-glib/as-store.h
@@ -63,20 +63,23 @@ struct _AsStoreClass
* @AS_STORE_LOAD_FLAG_FLATPAK_USER: Add flatpak user applications (obsolete)
* @AS_STORE_LOAD_FLAG_FLATPAK_SYSTEM: Add flatpak system applications (obsolete)
* @AS_STORE_LOAD_FLAG_IGNORE_INVALID: Ignore invalid files
+ * @AS_STORE_LOAD_FLAG_ONLY_UNCOMPRESSED: Ignore compressed files
+ * @AS_STORE_LOAD_FLAG_ONLY_MERGE_APPS: Ignore non-wildcard matches
*
* The flags to use when loading the store.
**/
typedef enum {
- AS_STORE_LOAD_FLAG_NONE = 0, /* Since: 0.1.2 */
- AS_STORE_LOAD_FLAG_APP_INFO_SYSTEM = 1, /* Since: 0.1.2 */
- AS_STORE_LOAD_FLAG_APP_INFO_USER = 2, /* Since: 0.1.2 */
- AS_STORE_LOAD_FLAG_APP_INSTALL = 4, /* Since: 0.1.2 */
- AS_STORE_LOAD_FLAG_APPDATA = 8, /* Since: 0.2.2 */
- AS_STORE_LOAD_FLAG_DESKTOP = 16, /* Since: 0.2.2 */
- AS_STORE_LOAD_FLAG_ALLOW_VETO = 32, /* Since: 0.2.5 */
- AS_STORE_LOAD_FLAG_FLATPAK_USER = 64, /* Since: 0.5.7 */
- AS_STORE_LOAD_FLAG_FLATPAK_SYSTEM = 128, /* Since: 0.5.7 */
- AS_STORE_LOAD_FLAG_IGNORE_INVALID = 256, /* Since: 0.5.8 */
+ AS_STORE_LOAD_FLAG_NONE = 0, /* Since: 0.1.2 */
+ AS_STORE_LOAD_FLAG_APP_INFO_SYSTEM = 1 << 0, /* Since: 0.1.2 */
+ AS_STORE_LOAD_FLAG_APP_INFO_USER = 1 << 1, /* Since: 0.1.2 */
+ AS_STORE_LOAD_FLAG_APP_INSTALL = 1 << 2, /* Since: 0.1.2 */
+ AS_STORE_LOAD_FLAG_APPDATA = 1 << 3, /* Since: 0.2.2 */
+ AS_STORE_LOAD_FLAG_DESKTOP = 1 << 4, /* Since: 0.2.2 */
+ AS_STORE_LOAD_FLAG_ALLOW_VETO = 1 << 5, /* Since: 0.2.5 */
+ AS_STORE_LOAD_FLAG_FLATPAK_USER = 1 << 6, /* Since: 0.5.7 */
+ AS_STORE_LOAD_FLAG_FLATPAK_SYSTEM = 1 << 7, /* Since: 0.5.7 */
+ AS_STORE_LOAD_FLAG_IGNORE_INVALID = 1 << 8, /* Since: 0.5.8 */
+ AS_STORE_LOAD_FLAG_ONLY_UNCOMPRESSED = 1 << 9, /* Since: 0.6.4 */
/*< private >*/
AS_STORE_LOAD_FLAG_LAST
} AsStoreLoadFlags;