lib/repo: Add timestamps to OstreeRepoFinderResult
Currently OstreeRepoFinderResult, a data structure used by pull code that supports P2P operations, has a hash table mapping refs to checksums but doesn't include timestamp information. This means that clients have no way of knowing just from the OstreeRepoFinderResult information if a commit being offered by a peer remote is an update or downgrade until they start pulling it. The client could check the summary or the commit metadata for the timestamps, but this requires adding the temporary remotes to the repo config, and ostree is already checking timestamps before returning the results, so I think it makes more sense for them to be returned rather than leaving it to the client. This limitation is especially important for offline computers, because for online computers the latest commit available from any remote is the latest commit, period. This commit adds a "ref_to_timestamp" hash table to OstreeRepoFinderResult that is symmetric to "ref_to_checksum" in that it shares the same keys. This is an API break, but it's part of the experimental API, and none of the current users of that (flatpak, eos-updater, and gnome-software) are affected. See the documentation for more details on "ref_to_timestamp". One thing to note is the data structure currently gets initialized in find_remotes_cb(), so only users of ostree_repo_find_remotes_async() will get them, not users of, say, ostree_repo_finder_resolve_all_async(). This is because the individual OstreeRepoFinder implementations don't currently access the timestamps (but I think this could be changed in the future if there's a need). This commit will allow P2P support to be added to flatpak_installation_list_installed_refs_for_update, which will allow GNOME Software to update apps from USB drives while offline (it's already possible online). Closes: #1518 Approved by: cgwalters
This commit is contained in:
1 parent
c4c2b5ebd1
commit
cb3360fca6
8 files changed
+189
-9
No files matched your search
@@ -436,6 +436,9 @@ G_DEFINE_BOXED_TYPE (OstreeRepoFinderResult, ostree_repo_finder_result,
|
||||
* priority
|
||||
* @ref_to_checksum: (element-type OstreeCollectionRef utf8) (transfer none):
|
||||
* map of collection–ref pairs to checksums provided by this result
|
||||
* @ref_to_timestamp: (element-type OstreeCollectionRef guint64) (nullable)
|
||||
* (transfer none): map of collection–ref pairs to timestamps provided by this
|
||||
* result
|
||||
* @summary_last_modified: Unix timestamp (seconds since the epoch, UTC) when
|
||||
* the summary file for the result was last modified, or `0` if this is unknown
|
||||
*
|
||||
@@ -450,6 +453,7 @@ ostree_repo_finder_result_new (OstreeRemote *remote,
|
||||
OstreeRepoFinder *finder,
|
||||
gint priority,
|
||||
GHashTable *ref_to_checksum,
|
||||
GHashTable *ref_to_timestamp,
|
||||
guint64 summary_last_modified)
|
||||
{
|
||||
g_autoptr(OstreeRepoFinderResult) result = NULL;
|
||||
@@ -463,6 +467,7 @@ ostree_repo_finder_result_new (OstreeRemote *remote,
|
||||
result->finder = g_object_ref (finder);
|
||||
result->priority = priority;
|
||||
result->ref_to_checksum = g_hash_table_ref (ref_to_checksum);
|
||||
result->ref_to_timestamp = ref_to_timestamp != NULL ? g_hash_table_ref (ref_to_timestamp) : NULL;
|
||||
result->summary_last_modified = summary_last_modified;
|
||||
|
||||
return g_steal_pointer (&result);
|
||||
@@ -484,7 +489,7 @@ ostree_repo_finder_result_dup (OstreeRepoFinderResult *result)
|
||||
|
||||
return ostree_repo_finder_result_new (result->remote, result->finder,
|
||||
result->priority, result->ref_to_checksum,
|
||||
result->summary_last_modified);
|
||||
result->ref_to_timestamp, result->summary_last_modified);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -554,6 +559,7 @@ ostree_repo_finder_result_free (OstreeRepoFinderResult *result)
|
||||
/* This may be NULL iff the result is freed half-way through find_remotes_cb()
|
||||
* in ostree-repo-pull.c, and at no other time. */
|
||||
g_clear_pointer (&result->ref_to_checksum, g_hash_table_unref);
|
||||
g_clear_pointer (&result->ref_to_timestamp, g_hash_table_unref);
|
||||
g_object_unref (result->finder);
|
||||
ostree_remote_unref (result->remote);
|
||||
g_free (result);
|
||||
|
||||
Reference in new issue
Block a user