diff --git a/common/xdg-app-dir.c b/common/xdg-app-dir.c index 681e7443..943a519d 100644 --- a/common/xdg-app-dir.c +++ b/common/xdg-app-dir.c @@ -616,6 +616,7 @@ xdg_app_dir_update_appstream (XdgAppDir *self, g_autofree char *tmpname = NULL; g_autoptr(GFile) active_tmp_link = NULL; g_autoptr(GFile) active_link = NULL; + g_autoptr(GFile) timestamp_file = NULL; g_autoptr(GError) tmp_error = NULL; if (!xdg_app_dir_ensure_repo (self, cancellable, error)) @@ -647,14 +648,25 @@ xdg_app_dir_update_appstream (XdgAppDir *self, remote_dir = g_file_get_child (appstream_dir, remote); arch_dir = g_file_get_child (remote_dir, arch); checkout_dir = g_file_get_child (arch_dir, new_checksum); + timestamp_file = g_file_get_child (arch_dir, ".timestamp"); + + arch_path = g_file_get_path (arch_dir); + if (g_mkdir_with_parents (arch_path, 0755) != 0) + { + glnx_set_error_from_errno (error); + return FALSE; + } if (old_checksum != NULL && new_checksum != NULL && strcmp (old_checksum, new_checksum) == 0 && g_file_query_exists (checkout_dir, NULL)) { + if (!g_file_replace_contents (timestamp_file, "", 0, NULL, FALSE, + G_FILE_CREATE_REPLACE_DESTINATION, NULL, NULL, error)) + return FALSE; + if (out_changed) *out_changed = FALSE; - return TRUE; /* No changes, don't checkout */ } @@ -667,13 +679,6 @@ xdg_app_dir_update_appstream (XdgAppDir *self, if (file_info == NULL) return FALSE; - arch_path = g_file_get_path (arch_dir); - if (g_mkdir_with_parents (arch_path, 0755) != 0) - { - glnx_set_error_from_errno (error); - return FALSE; - } - if (!ostree_repo_checkout_tree (self->repo, self->user ? OSTREE_REPO_CHECKOUT_MODE_USER : OSTREE_REPO_CHECKOUT_MODE_NONE, OSTREE_REPO_CHECKOUT_OVERWRITE_NONE, @@ -702,6 +707,10 @@ xdg_app_dir_update_appstream (XdgAppDir *self, g_warning ("Unable to remove old appstream checkout: %s\n", tmp_error->message); } + if (!g_file_replace_contents (timestamp_file, "", 0, NULL, FALSE, + G_FILE_CREATE_REPLACE_DESTINATION, NULL, NULL, error)) + return FALSE; + if (out_changed) *out_changed = TRUE; return TRUE; diff --git a/lib/xdg-app-remote.c b/lib/xdg-app-remote.c index 6087b61d..8d45a785 100644 --- a/lib/xdg-app-remote.c +++ b/lib/xdg-app-remote.c @@ -145,6 +145,22 @@ xdg_app_remote_get_appstream_dir (XdgAppRemote *self, subdir); } +GFile * +xdg_app_remote_get_appstream_timestamp (XdgAppRemote *self, + const char *arch) +{ + XdgAppRemotePrivate *priv = xdg_app_remote_get_instance_private (self); + g_autoptr(GFile) dir = NULL; + g_autofree char *subdir = NULL; + + if (arch == NULL) + arch = xdg_app_get_arch (); + + subdir = g_strdup_printf ("appstream/%s/%s/.timestamp", priv->name, arch); + return g_file_resolve_relative_path (xdg_app_dir_get_path (priv->dir), + subdir); +} + char * xdg_app_remote_get_url (XdgAppRemote *self) { diff --git a/lib/xdg-app-remote.h b/lib/xdg-app-remote.h index ee107734..a50bbac4 100644 --- a/lib/xdg-app-remote.h +++ b/lib/xdg-app-remote.h @@ -51,6 +51,8 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppRemote, g_object_unref) XDG_APP_EXTERN const char * xdg_app_remote_get_name (XdgAppRemote *self); XDG_APP_EXTERN GFile * xdg_app_remote_get_appstream_dir (XdgAppRemote *self, const char *arch); +XDG_APP_EXTERN GFile * xdg_app_remote_get_appstream_timestamp (XdgAppRemote *self, + const char *arch); XDG_APP_EXTERN char * xdg_app_remote_get_url (XdgAppRemote *self); XDG_APP_EXTERN char * xdg_app_remote_get_title (XdgAppRemote *self); XDG_APP_EXTERN gboolean xdg_app_remote_get_gpg_verify (XdgAppRemote *self);