deltas: Support passing filename to ostree_repo_static_delta_execute_offline

If you pass a diriectory it will look for the "superblock" child, otherwise
it will use the file as the superblock. I need this in xdg-app to be able
to install any filename as a bundle.
This commit is contained in:
Alexander Larsson 2015-10-16 12:54:01 +02:00
parent dac57b6410
commit ec56fea821
2 changed files with 19 additions and 4 deletions

View File

@ -206,7 +206,7 @@ _ostree_repo_static_delta_part_have_all_objects (OstreeRepo *repo,
/** /**
* ostree_repo_static_delta_execute_offline: * ostree_repo_static_delta_execute_offline:
* @self: Repo * @self: Repo
* @dir: Path to a directory containing static delta data * @dir_or_file: Path to a directory containing static delta data, or directly to the superblock
* @skip_validation: If %TRUE, assume data integrity * @skip_validation: If %TRUE, assume data integrity
* @cancellable: Cancellable * @cancellable: Cancellable
* @error: Error * @error: Error
@ -218,20 +218,35 @@ _ostree_repo_static_delta_part_have_all_objects (OstreeRepo *repo,
*/ */
gboolean gboolean
ostree_repo_static_delta_execute_offline (OstreeRepo *self, ostree_repo_static_delta_execute_offline (OstreeRepo *self,
GFile *dir, GFile *dir_or_file,
gboolean skip_validation, gboolean skip_validation,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
guint i, n; guint i, n;
g_autoptr(GFile) meta_file = g_file_get_child (dir, "superblock"); g_autoptr(GFile) meta_file = NULL;
g_autoptr(GFile) dir = NULL;
g_autoptr(GVariant) meta = NULL; g_autoptr(GVariant) meta = NULL;
g_autoptr(GVariant) headers = NULL; g_autoptr(GVariant) headers = NULL;
g_autoptr(GVariant) metadata = NULL; g_autoptr(GVariant) metadata = NULL;
g_autoptr(GVariant) fallback = NULL; g_autoptr(GVariant) fallback = NULL;
g_autofree char *to_checksum = NULL; g_autofree char *to_checksum = NULL;
g_autofree char *from_checksum = NULL; g_autofree char *from_checksum = NULL;
GFileType file_type;
file_type = g_file_query_file_type (dir_or_file, 0, cancellable);
if (file_type == G_FILE_TYPE_DIRECTORY)
{
dir = g_object_ref (dir_or_file);
meta_file = g_file_get_child (dir, "superblock");
}
else
{
meta_file = g_object_ref (dir_or_file);
dir = g_file_get_parent (meta_file);
}
if (!ot_util_variant_map (meta_file, G_VARIANT_TYPE (OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT), if (!ot_util_variant_map (meta_file, G_VARIANT_TYPE (OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT),
FALSE, &meta, error)) FALSE, &meta, error))

View File

@ -594,7 +594,7 @@ gboolean ostree_repo_static_delta_generate (OstreeRepo *self,
GError **error); GError **error);
gboolean ostree_repo_static_delta_execute_offline (OstreeRepo *self, gboolean ostree_repo_static_delta_execute_offline (OstreeRepo *self,
GFile *dir, GFile *dir_or_file,
gboolean skip_validation, gboolean skip_validation,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);