mirror of
https://github.com/flatpak/flatpak.git
synced 2026-05-07 07:25:45 -04:00
lib: Add a flag-using _full version of list/fetch_remote_ref
This adds the flag FLATPAK_QUERY_FLAGS_ONLY_CACHED to use the new code for this. Closes: #2859 Approved by: alexlarsson
This commit is contained in:
committed by
Atomic Bot
parent
aa24754aa0
commit
ad11954bf7
@@ -2342,6 +2342,31 @@ flatpak_installation_list_remote_refs_sync (FlatpakInstallation *self,
|
||||
const char *remote_or_uri,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
return flatpak_installation_list_remote_refs_sync_full (self, remote_or_uri, 0, cancellable, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* flatpak_installation_list_remote_refs_sync_full:
|
||||
* @self: a #FlatpakInstallation
|
||||
* @remote_or_uri: the name or URI of the remote
|
||||
* @flags: set of #FlatpakQueryFlags
|
||||
* @cancellable: (nullable): a #GCancellable
|
||||
* @error: return location for a #GError
|
||||
*
|
||||
* Lists all the applications and runtimes in a remote.
|
||||
*
|
||||
* Returns: (transfer container) (element-type FlatpakRemoteRef): a GPtrArray of
|
||||
* #FlatpakRemoteRef instances
|
||||
*
|
||||
* Since: 1.3.3
|
||||
*/
|
||||
GPtrArray *
|
||||
flatpak_installation_list_remote_refs_sync_full (FlatpakInstallation *self,
|
||||
const char *remote_or_uri,
|
||||
FlatpakQueryFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(FlatpakDir) dir = NULL;
|
||||
g_autoptr(GPtrArray) refs = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
@@ -2355,7 +2380,7 @@ flatpak_installation_list_remote_refs_sync (FlatpakInstallation *self,
|
||||
if (dir == NULL)
|
||||
return NULL;
|
||||
|
||||
state = flatpak_dir_get_remote_state (dir, remote_or_uri, FALSE, cancellable, error);
|
||||
state = flatpak_dir_get_remote_state (dir, remote_or_uri, (flags & FLATPAK_QUERY_FLAGS_ONLY_CACHED) != 0, cancellable, error);
|
||||
if (state == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -2403,6 +2428,40 @@ flatpak_installation_fetch_remote_ref_sync (FlatpakInstallation *self,
|
||||
const char *branch,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
return flatpak_installation_fetch_remote_ref_sync_full (self, remote_name,
|
||||
kind, name, arch, branch, 0,
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* flatpak_installation_fetch_remote_ref_sync_full:
|
||||
* @self: a #FlatpakInstallation
|
||||
* @remote_name: the name of the remote
|
||||
* @kind: what this ref contains (an #FlatpakRefKind)
|
||||
* @name: name of the app/runtime to fetch
|
||||
* @arch: (nullable): which architecture to fetch (default: current architecture)
|
||||
* @branch: (nullable): which branch to fetch (default: 'master')
|
||||
* @flags: set of #FlatpakQueryFlags
|
||||
* @cancellable: (nullable): a #GCancellable
|
||||
* @error: return location for a #GError
|
||||
*
|
||||
* Gets the current remote branch of a ref in the remote.
|
||||
*
|
||||
* Returns: (transfer full): a #FlatpakRemoteRef instance, or %NULL
|
||||
*
|
||||
* Since: 1.3.3
|
||||
*/
|
||||
FlatpakRemoteRef *
|
||||
flatpak_installation_fetch_remote_ref_sync_full (FlatpakInstallation *self,
|
||||
const char *remote_name,
|
||||
FlatpakRefKind kind,
|
||||
const char *name,
|
||||
const char *arch,
|
||||
const char *branch,
|
||||
FlatpakQueryFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(FlatpakDir) dir = NULL;
|
||||
g_autoptr(GHashTable) ht = NULL;
|
||||
@@ -2419,7 +2478,7 @@ flatpak_installation_fetch_remote_ref_sync (FlatpakInstallation *self,
|
||||
if (dir == NULL)
|
||||
return NULL;
|
||||
|
||||
state = flatpak_dir_get_remote_state (dir, remote_name, FALSE, cancellable, error);
|
||||
state = flatpak_dir_get_remote_state (dir, remote_name, (flags & FLATPAK_QUERY_FLAGS_ONLY_CACHED) != 0, cancellable, error);
|
||||
if (state == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -121,6 +121,22 @@ typedef enum {
|
||||
FLATPAK_LAUNCH_FLAGS_DO_NOT_REAP = (1 << 0),
|
||||
} FlatpakLaunchFlags;
|
||||
|
||||
/**
|
||||
* FlatpakQueryFlags:
|
||||
* @FLATPAK_QUERY_FLAGS_NONE: Default
|
||||
* @FLATPAK_QUERY_FLAGS_ONLY_CACHED: Don't do any network i/o, but only return cached data.
|
||||
* This can return stale data, or a #FLATPAK_ERROR_NOT_CACHED error, however it is a
|
||||
* lot more efficient if you're doing many requests.
|
||||
*
|
||||
* Flags to alter the behavior of e.g flatpak_installation_list_remote_refs_full().
|
||||
*
|
||||
* Since: 1.3.3
|
||||
*/
|
||||
typedef enum {
|
||||
FLATPAK_QUERY_FLAGS_NONE = 0,
|
||||
FLATPAK_QUERY_FLAGS_ONLY_CACHED = (1 << 0),
|
||||
} FlatpakQueryFlags;
|
||||
|
||||
/**
|
||||
* FlatpakStorageType:
|
||||
* @FLATPAK_STORAGE_TYPE_DEFAULT: default
|
||||
@@ -369,6 +385,11 @@ FLATPAK_EXTERN GPtrArray * flatpak_installation_list_remote_refs_sync (Fla
|
||||
const char *remote_or_uri,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
FLATPAK_EXTERN GPtrArray * flatpak_installation_list_remote_refs_sync_full (FlatpakInstallation *self,
|
||||
const char *remote_or_uri,
|
||||
FlatpakQueryFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
FLATPAK_EXTERN FlatpakRemoteRef *flatpak_installation_fetch_remote_ref_sync (FlatpakInstallation *self,
|
||||
const char *remote_name,
|
||||
FlatpakRefKind kind,
|
||||
@@ -377,6 +398,15 @@ FLATPAK_EXTERN FlatpakRemoteRef *flatpak_installation_fetch_remote_ref_sync (Fl
|
||||
const char *branch,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
FLATPAK_EXTERN FlatpakRemoteRef *flatpak_installation_fetch_remote_ref_sync_full (FlatpakInstallation *self,
|
||||
const char *remote_name,
|
||||
FlatpakRefKind kind,
|
||||
const char *name,
|
||||
const char *arch,
|
||||
const char *branch,
|
||||
FlatpakQueryFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
FLATPAK_EXTERN gboolean flatpak_installation_update_appstream_sync (FlatpakInstallation *self,
|
||||
const char *remote_name,
|
||||
const char *arch,
|
||||
|
||||
Reference in New Issue
Block a user