ostree: Use #defines for well-known metadata key names

Rather than hard-coding the names as strings. This makes the code a
little more maintainable.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #826
Approved by: cgwalters
This commit is contained in:
Philip Withnall 2017-05-05 11:28:42 +01:00 committed by Atomic Bot
parent a946c3d423
commit c1290177a3
2 changed files with 9 additions and 6 deletions

View File

@ -26,6 +26,7 @@
#include "ot-builtins.h"
#include "ostree.h"
#include "otutil.h"
#include "ostree-core-private.h"
static gboolean opt_delete;
static char *opt_gpg_homedir;
@ -85,7 +86,7 @@ delete_signatures (OstreeRepo *repo,
g_variant_dict_init (&metadata_dict, old_metadata);
signature_data = g_variant_dict_lookup_value (&metadata_dict,
"ostree.gpgsigs",
_OSTREE_METADATA_GPGSIGS_NAME,
G_VARIANT_TYPE ("aay"));
/* Taking the approach of deleting whatever matches we find for the
@ -154,7 +155,7 @@ delete_signatures (OstreeRepo *repo,
/* Update the metadata dictionary. */
if (g_queue_is_empty (&signatures))
{
g_variant_dict_remove (&metadata_dict, "ostree.gpgsigs");
g_variant_dict_remove (&metadata_dict, _OSTREE_METADATA_GPGSIGS_NAME);
}
else
{
@ -170,7 +171,7 @@ delete_signatures (OstreeRepo *repo,
}
g_variant_dict_insert_value (&metadata_dict,
"ostree.gpgsigs",
_OSTREE_METADATA_GPGSIGS_NAME,
g_variant_builder_end (&signature_builder));
}

View File

@ -26,6 +26,8 @@
#include <err.h>
#include "ostree-repo-private.h"
#include "ostree-repo-static-delta-private.h"
#include "ot-dump.h"
#include "otutil.h"
#include "ot-admin-functions.h"
@ -268,17 +270,17 @@ ot_dump_summary_bytes (GBytes *summary_bytes,
g_autofree gchar *value_str = NULL;
const gchar *pretty_key = NULL;
if (g_strcmp0 (key, "ostree.static-deltas") == 0)
if (g_strcmp0 (key, OSTREE_SUMMARY_STATIC_DELTAS) == 0)
{
pretty_key = "Static Deltas";
value_str = g_variant_print (value, FALSE);
}
else if (g_strcmp0 (key, "ostree.summary.last-modified") == 0)
else if (g_strcmp0 (key, OSTREE_SUMMARY_LAST_MODIFIED) == 0)
{
pretty_key = "Last-Modified";
value_str = uint64_secs_to_iso8601 (GUINT64_FROM_BE (g_variant_get_uint64 (value)));
}
else if (g_strcmp0 (key, "ostree.summary.expires") == 0)
else if (g_strcmp0 (key, OSTREE_SUMMARY_EXPIRES) == 0)
{
pretty_key = "Expires";
value_str = uint64_secs_to_iso8601 (GUINT64_FROM_BE (g_variant_get_uint64 (value)));