diff options
author | Matthew Leeds <matthew.leeds@endlessm.com> | 2018-03-28 00:31:05 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-04-03 15:50:40 +0000 |
commit | cb3360fca656a478ba407c879f3cc675da78fe87 (patch) | |
tree | 4066c90156f0718403ac5535b3903f50d298a460 /src/libostree/ostree-repo-finder.h | |
parent | c4c2b5ebd155f9d17531db4ab9c2516699132745 (diff) | |
download | ostree-cb3360fca656a478ba407c879f3cc675da78fe87.tar.gz |
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
Diffstat (limited to 'src/libostree/ostree-repo-finder.h')
-rw-r--r-- | src/libostree/ostree-repo-finder.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/libostree/ostree-repo-finder.h b/src/libostree/ostree-repo-finder.h index bb1a437e..e622c9a6 100644 --- a/src/libostree/ostree-repo-finder.h +++ b/src/libostree/ostree-repo-finder.h @@ -99,6 +99,8 @@ GPtrArray *ostree_repo_finder_resolve_all_finish (GAsyncResult *result, * @ref_to_checksum: (element-type OstreeCollectionRef utf8): map of collection–ref * pairs to checksums provided by this remote; values may be %NULL to * indicate this remote doesn’t provide that ref + * @ref_to_timestamp: (element-type OstreeCollectionRef guint64) (nullable): map of + * collection–ref pairs to timestamps; values may be 0 for various reasons * @summary_last_modified: Unix timestamp (seconds since the epoch, UTC) when * the summary file on the remote was last modified, or `0` if unknown * @@ -122,6 +124,15 @@ GPtrArray *ostree_repo_finder_resolve_all_finish (GAsyncResult *result, * should be available locally, so the details for each checksum can be looked * up using ostree_repo_load_commit(). * + * @ref_to_timestamp provides timestamps for the set of refs in + * @ref_to_checksum. The refs are keys (of type #OstreeCollectionRef) and the + * values are guint64 pointers with the timestamp associated with the checksum + * provided in @ref_to_checksum. @ref_to_timestamp can be %NULL, and when it's + * not, the timestamps are zero when any of the following conditions are met: + * (1) the override-commit-ids option was used on + * ostree_repo_find_remotes_async (2) there was an error in trying to get the + * commit metadata (3) the checksum for this ref is %NULL in @ref_to_checksum. + * * Since: 2017.8 */ typedef struct @@ -131,9 +142,10 @@ typedef struct gint priority; GHashTable *ref_to_checksum; guint64 summary_last_modified; + GHashTable *ref_to_timestamp; /*< private >*/ - gpointer padding[4]; + gpointer padding[3]; } OstreeRepoFinderResult; _OSTREE_PUBLIC @@ -144,6 +156,7 @@ OstreeRepoFinderResult *ostree_repo_finder_result_new (OstreeRemote *remote, OstreeRepoFinder *finder, gint priority, GHashTable *ref_to_checksum, + GHashTable *ref_to_timestamp, guint64 summary_last_modified); _OSTREE_PUBLIC OstreeRepoFinderResult *ostree_repo_finder_result_dup (OstreeRepoFinderResult *result); |