Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #3482 from abderrahim/flatpak-progress
Add a FlatpakProgress object
  • Loading branch information
alexlarsson committed Mar 27, 2020
2 parents d222d4e + c222f03 commit e2c8838
Show file tree
Hide file tree
Showing 12 changed files with 787 additions and 680 deletions.
17 changes: 3 additions & 14 deletions app/flatpak-builtins-utils.c
Expand Up @@ -619,11 +619,6 @@ get_file_age (GFile *file)
return (guint64) (now - mtime);
}

static void
no_progress_cb (OstreeAsyncProgress *progress, gpointer user_data)
{
}

static guint64
get_appstream_timestamp (FlatpakDir *dir,
const char *remote,
Expand All @@ -650,7 +645,6 @@ update_appstream (GPtrArray *dirs,
GError **error)
{
gboolean changed;
gboolean res;
int i, j;

g_return_val_if_fail (dirs != NULL, FALSE);
Expand All @@ -672,7 +666,6 @@ update_appstream (GPtrArray *dirs,
for (i = 0; remotes[i] != NULL; i++)
{
g_autoptr(GError) local_error = NULL;
g_autoptr(OstreeAsyncProgressFinish) progress = NULL;
guint64 ts_file_age;

ts_file_age = get_appstream_timestamp (dir, remotes[i], arch);
Expand Down Expand Up @@ -708,9 +701,8 @@ update_appstream (GPtrArray *dirs,
g_print ("\n");
}
}
progress = ostree_async_progress_new_and_connect (no_progress_cb, NULL);
if (!flatpak_dir_update_appstream (dir, remotes[i], arch, &changed,
progress, cancellable, &local_error))
NULL, cancellable, &local_error))
{
if (quiet)
g_debug ("%s: %s", _("Error updating"), local_error->message);
Expand All @@ -730,7 +722,6 @@ update_appstream (GPtrArray *dirs,

if (flatpak_dir_has_remote (dir, remote, NULL))
{
g_autoptr(OstreeAsyncProgressFinish) progress = NULL;
guint64 ts_file_age;

found = TRUE;
Expand All @@ -744,10 +735,8 @@ update_appstream (GPtrArray *dirs,
else
g_debug ("%s:%s appstream age %" G_GUINT64_FORMAT " is greater than ttl %" G_GUINT64_FORMAT, remote, arch, ts_file_age, ttl);

progress = ostree_async_progress_new_and_connect (no_progress_cb, NULL);
res = flatpak_dir_update_appstream (dir, remote, arch, &changed,
progress, cancellable, error);
if (!res)
if (!flatpak_dir_update_appstream (dir, remote, arch, &changed,
NULL, cancellable, error))
return FALSE;
}
}
Expand Down
2 changes: 2 additions & 0 deletions common/Makefile.am.inc
Expand Up @@ -142,6 +142,8 @@ libflatpak_common_la_SOURCES = \
common/flatpak-oci-registry.c \
common/flatpak-portal-error.c \
common/flatpak-portal-error.h \
common/flatpak-progress-private.h \
common/flatpak-progress.c \
common/flatpak-ref.c \
common/flatpak-related-ref-private.h \
common/flatpak-related-ref.c \
Expand Down
12 changes: 6 additions & 6 deletions common/flatpak-dir-private.h
Expand Up @@ -25,6 +25,7 @@

#include "flatpak-common-types-private.h"
#include "flatpak-context-private.h"
#include "flatpak-progress-private.h"
#include "flatpak-variant-private.h"
#include "libglnx/libglnx.h"

Expand Down Expand Up @@ -85,7 +86,6 @@ GType flatpak_deploy_get_type (void);
#define FLATPAK_REPO_COLLECTION_ID_KEY "CollectionID"
#define FLATPAK_REPO_DEPLOY_COLLECTION_ID_KEY "DeployCollectionID"

#define FLATPAK_DEFAULT_UPDATE_INTERVAL_MS 100
#define FLATPAK_CLI_UPDATE_INTERVAL_MS 300

#define FLATPAK_SPARSE_CACHE_KEY_ENDOFLINE "eol"
Expand Down Expand Up @@ -561,7 +561,7 @@ gboolean flatpak_dir_update_appstream (FlatpakDir *self,
const char *remote,
const char *arch,
gboolean *out_changed,
OstreeAsyncProgress *progress,
FlatpakProgress *progress,
GCancellable *cancellable,
GError **error);
gboolean flatpak_dir_pull (FlatpakDir *self,
Expand All @@ -575,15 +575,15 @@ gboolean flatpak_dir_pull (FlatpakDir *self,
OstreeRepo *repo,
FlatpakPullFlags flatpak_flags,
OstreeRepoPullFlags flags,
OstreeAsyncProgress *progress,
FlatpakProgress *progress,
GCancellable *cancellable,
GError **error);
gboolean flatpak_dir_pull_untrusted_local (FlatpakDir *self,
const char *src_path,
const char *remote_name,
const char *ref,
const char **subpaths,
OstreeAsyncProgress *progress,
FlatpakProgress *progress,
GCancellable *cancellable,
GError **error);
gboolean flatpak_dir_list_refs_for_name (FlatpakDir *self,
Expand Down Expand Up @@ -679,7 +679,7 @@ gboolean flatpak_dir_install (FlatpakDir *self,
GFile *sideload_repo,
GBytes *require_metadata,
const char *token,
OstreeAsyncProgress *progress,
FlatpakProgress *progress,
GCancellable *cancellable,
GError **error);
char *flatpak_dir_ensure_bundle_remote (FlatpakDir *self,
Expand Down Expand Up @@ -730,7 +730,7 @@ gboolean flatpak_dir_update (FlatpakDir *self,
GFile *sideload_repo,
GBytes *require_metadata,
const char *token,
OstreeAsyncProgress *progress,
FlatpakProgress *progress,
GCancellable *cancellable,
GError **error);
gboolean flatpak_dir_uninstall (FlatpakDir *self,
Expand Down

0 comments on commit e2c8838

Please sign in to comment.