core: Add OSTREE_OBJECT_TYPE_COMMIT_META
This is cleaner than the loose_path_with_suffix approach Closes: #359 Approved by: cgwalters
This commit is contained in:
parent
55f5f73d80
commit
23049bbd01
|
|
@ -128,13 +128,6 @@ _ostree_loose_path (char *buf,
|
|||
OstreeObjectType objtype,
|
||||
OstreeRepoMode repo_mode);
|
||||
|
||||
void
|
||||
_ostree_loose_path_with_suffix (char *buf,
|
||||
const char *checksum,
|
||||
OstreeObjectType objtype,
|
||||
OstreeRepoMode repo_mode,
|
||||
const char *suffix);
|
||||
|
||||
#define _OSTREE_METADATA_GPGSIGS_NAME "ostree.gpgsigs"
|
||||
#define _OSTREE_METADATA_GPGSIGS_TYPE G_VARIANT_TYPE ("aay")
|
||||
|
||||
|
|
|
|||
|
|
@ -1047,6 +1047,8 @@ ostree_object_type_to_string (OstreeObjectType objtype)
|
|||
return "commit";
|
||||
case OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT:
|
||||
return "tombstone-commit";
|
||||
case OSTREE_OBJECT_TYPE_COMMIT_META:
|
||||
return "commitmeta";
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return NULL;
|
||||
|
|
@ -1070,6 +1072,10 @@ ostree_object_type_from_string (const char *str)
|
|||
return OSTREE_OBJECT_TYPE_DIR_META;
|
||||
else if (!strcmp (str, "commit"))
|
||||
return OSTREE_OBJECT_TYPE_COMMIT;
|
||||
else if (!strcmp (str, "tombstone-commit"))
|
||||
return OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT;
|
||||
else if (!strcmp (str, "commitmeta"))
|
||||
return OSTREE_OBJECT_TYPE_COMMIT_META;
|
||||
g_assert_not_reached ();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1414,7 +1420,13 @@ _ostree_loose_path (char *buf,
|
|||
OstreeObjectType objtype,
|
||||
OstreeRepoMode mode)
|
||||
{
|
||||
_ostree_loose_path_with_suffix (buf, checksum, objtype, mode, "");
|
||||
*buf = checksum[0];
|
||||
buf++;
|
||||
*buf = checksum[1];
|
||||
buf++;
|
||||
snprintf (buf, _OSTREE_LOOSE_PATH_MAX - 2, "/%s.%s%s",
|
||||
checksum + 2, ostree_object_type_to_string (objtype),
|
||||
(!OSTREE_OBJECT_TYPE_IS_META (objtype) && mode == OSTREE_REPO_MODE_ARCHIVE_Z2) ? "z" : "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1442,33 +1454,6 @@ _ostree_header_gfile_info_new (mode_t mode, uid_t uid, gid_t gid)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* _ostree_loose_path_with_suffix:
|
||||
* @buf: Output buffer, must be _OSTREE_LOOSE_PATH_MAX in size
|
||||
* @checksum: ASCII checksum
|
||||
* @objtype: Object type
|
||||
* @mode: Repository mode
|
||||
*
|
||||
* Like _ostree_loose_path, but also append a further arbitrary
|
||||
* suffix; useful for finding non-core objects.
|
||||
*/
|
||||
void
|
||||
_ostree_loose_path_with_suffix (char *buf,
|
||||
const char *checksum,
|
||||
OstreeObjectType objtype,
|
||||
OstreeRepoMode mode,
|
||||
const char *suffix)
|
||||
{
|
||||
*buf = checksum[0];
|
||||
buf++;
|
||||
*buf = checksum[1];
|
||||
buf++;
|
||||
snprintf (buf, _OSTREE_LOOSE_PATH_MAX - 2, "/%s.%s%s%s",
|
||||
checksum + 2, ostree_object_type_to_string (objtype),
|
||||
(!OSTREE_OBJECT_TYPE_IS_META (objtype) && mode == OSTREE_REPO_MODE_ARCHIVE_Z2) ? "z" : "",
|
||||
suffix);
|
||||
}
|
||||
|
||||
/*
|
||||
* _ostree_get_relative_object_path:
|
||||
* @checksum: ASCII checksum string
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ G_BEGIN_DECLS
|
|||
* @OSTREE_OBJECT_TYPE_DIR_META: Directory metadata
|
||||
* @OSTREE_OBJECT_TYPE_COMMIT: Toplevel object, refers to tree and dirmeta for root
|
||||
* @OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT: Toplevel object, refers to a deleted commit
|
||||
* @OSTREE_OBJECT_TYPE_COMMIT_META: Detached metadata for a commit
|
||||
*
|
||||
* Enumeration for core object types; %OSTREE_OBJECT_TYPE_FILE is for
|
||||
* content, the other types are metadata.
|
||||
|
|
@ -82,6 +83,7 @@ typedef enum {
|
|||
OSTREE_OBJECT_TYPE_DIR_META = 3, /* .dirmeta */
|
||||
OSTREE_OBJECT_TYPE_COMMIT = 4, /* .commit */
|
||||
OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT = 5, /* .commit-tombstone */
|
||||
OSTREE_OBJECT_TYPE_COMMIT_META = 6, /* .commitmeta */
|
||||
} OstreeObjectType;
|
||||
|
||||
/**
|
||||
|
|
@ -90,14 +92,14 @@ typedef enum {
|
|||
*
|
||||
* Returns: %TRUE if object type is metadata
|
||||
*/
|
||||
#define OSTREE_OBJECT_TYPE_IS_META(t) (t >= 2 && t <= 5)
|
||||
#define OSTREE_OBJECT_TYPE_IS_META(t) (t >= 2 && t <= 6)
|
||||
|
||||
/**
|
||||
* OSTREE_OBJECT_TYPE_LAST:
|
||||
*
|
||||
* Last valid object type; use this to validate ranges.
|
||||
*/
|
||||
#define OSTREE_OBJECT_TYPE_LAST OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT
|
||||
#define OSTREE_OBJECT_TYPE_LAST OSTREE_OBJECT_TYPE_COMMIT_META
|
||||
|
||||
/**
|
||||
* OSTREE_DIRMETA_GVARIANT_FORMAT:
|
||||
|
|
|
|||
|
|
@ -2058,8 +2058,7 @@ _ostree_repo_get_commit_metadata_loose_path (OstreeRepo *self,
|
|||
const char *checksum)
|
||||
{
|
||||
char buf[_OSTREE_LOOSE_PATH_MAX];
|
||||
_ostree_loose_path_with_suffix (buf, checksum, OSTREE_OBJECT_TYPE_COMMIT, self->mode,
|
||||
"meta");
|
||||
_ostree_loose_path (buf, checksum, OSTREE_OBJECT_TYPE_COMMIT_META, self->mode);
|
||||
return g_file_resolve_relative_path (self->objects_dir, buf);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1316,8 +1316,7 @@ enqueue_one_object_request (OtPullData *pull_data,
|
|||
if (is_detached_meta)
|
||||
{
|
||||
char buf[_OSTREE_LOOSE_PATH_MAX];
|
||||
_ostree_loose_path_with_suffix (buf, checksum, OSTREE_OBJECT_TYPE_COMMIT,
|
||||
pull_data->remote_mode, "meta");
|
||||
_ostree_loose_path (buf, checksum, OSTREE_OBJECT_TYPE_COMMIT_META, pull_data->remote_mode);
|
||||
obj_uri = suburi_new (pull_data->base_uri, "objects", buf, NULL);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -3120,8 +3120,7 @@ ostree_repo_delete_object (OstreeRepo *self,
|
|||
{
|
||||
char meta_loose[_OSTREE_LOOSE_PATH_MAX];
|
||||
|
||||
_ostree_loose_path_with_suffix (meta_loose, sha256,
|
||||
OSTREE_OBJECT_TYPE_COMMIT, self->mode, "meta");
|
||||
_ostree_loose_path (meta_loose, sha256, OSTREE_OBJECT_TYPE_COMMIT_META, self->mode);
|
||||
|
||||
do
|
||||
res = unlinkat (self->objects_dir_fd, meta_loose, 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue