core: Propagate GCancellable a bit from the import APIs

This commit is contained in:
Colin Walters 2011-11-30 22:20:25 -05:00
parent 702c38739e
commit 23d01d97dd
3 changed files with 28 additions and 17 deletions

View File

@ -638,6 +638,7 @@ write_gvariant_to_tmp (OstreeRepo *self,
GVariant *variant, GVariant *variant,
GFile **out_tmpname, GFile **out_tmpname,
GChecksum **out_checksum, GChecksum **out_checksum,
GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
@ -651,7 +652,7 @@ write_gvariant_to_tmp (OstreeRepo *self,
g_variant_get_size (serialized), g_variant_get_size (serialized),
NULL); NULL);
if (!stage_and_checksum (self, OSTREE_OBJECT_TYPE_META, if (!stage_and_checksum (self, OSTREE_OBJECT_TYPE_META,
mem, &ret_tmpname, &ret_checksum, NULL, error)) mem, &ret_tmpname, &ret_checksum, cancellable, error))
goto out; goto out;
ret = TRUE; ret = TRUE;
@ -676,6 +677,7 @@ import_gvariant_object (OstreeRepo *self,
OstreeSerializedVariantType type, OstreeSerializedVariantType type,
GVariant *variant, GVariant *variant,
GChecksum **out_checksum, GChecksum **out_checksum,
GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
@ -683,13 +685,13 @@ import_gvariant_object (OstreeRepo *self,
GChecksum *ret_checksum = NULL; GChecksum *ret_checksum = NULL;
gboolean did_exist; gboolean did_exist;
if (!write_gvariant_to_tmp (self, type, variant, &tmp_path, &ret_checksum, error)) if (!write_gvariant_to_tmp (self, type, variant, &tmp_path, &ret_checksum, cancellable, error))
goto out; goto out;
if (!ostree_repo_store_object_trusted (self, tmp_path, if (!ostree_repo_store_object_trusted (self, tmp_path,
g_checksum_get_string (ret_checksum), g_checksum_get_string (ret_checksum),
OSTREE_OBJECT_TYPE_META, OSTREE_OBJECT_TYPE_META,
FALSE, &did_exist, error)) FALSE, &did_exist, cancellable, error))
goto out; goto out;
ret = TRUE; ret = TRUE;
@ -737,6 +739,7 @@ import_directory_meta (OstreeRepo *self,
GFile *f, GFile *f,
GVariant **out_variant, GVariant **out_variant,
GChecksum **out_checksum, GChecksum **out_checksum,
GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
@ -746,15 +749,15 @@ import_directory_meta (OstreeRepo *self,
f_info = g_file_query_info (f, OSTREE_GIO_FAST_QUERYINFO, f_info = g_file_query_info (f, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL, error); cancellable, error);
if (!f_info) if (!f_info)
goto out; goto out;
if (!ostree_get_directory_metadata (f, f_info, &dirmeta, NULL, error)) if (!ostree_get_directory_metadata (f, f_info, &dirmeta, cancellable, error))
goto out; goto out;
if (!import_gvariant_object (self, OSTREE_SERIALIZED_DIRMETA_VARIANT, if (!import_gvariant_object (self, OSTREE_SERIALIZED_DIRMETA_VARIANT,
dirmeta, &ret_checksum, error)) dirmeta, &ret_checksum, cancellable, error))
goto out; goto out;
ret = TRUE; ret = TRUE;
@ -827,6 +830,7 @@ link_object_trusted (OstreeRepo *self,
OstreeObjectType objtype, OstreeObjectType objtype,
gboolean overwrite, gboolean overwrite,
gboolean *did_exist, gboolean *did_exist,
GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
@ -879,6 +883,7 @@ archive_file_trusted (OstreeRepo *self,
const char *checksum, const char *checksum,
gboolean overwrite, gboolean overwrite,
gboolean *did_exist, gboolean *did_exist,
GCancellable *cancellable,
GError **error) GError **error)
{ {
GFileOutputStream *out = NULL; GFileOutputStream *out = NULL;
@ -893,13 +898,13 @@ archive_file_trusted (OstreeRepo *self,
if (overwrite) if (overwrite)
{ {
out = g_file_replace (dest_file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, error); out = g_file_replace (dest_file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, cancellable, error);
if (!out) if (!out)
goto out; goto out;
} }
else else
{ {
out = g_file_create (dest_file, 0, NULL, &temp_error); out = g_file_create (dest_file, 0, cancellable, &temp_error);
if (!out) if (!out)
{ {
if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_EXISTS)) if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
@ -916,10 +921,10 @@ archive_file_trusted (OstreeRepo *self,
if (out) if (out)
{ {
if (!ostree_pack_file ((GOutputStream*)out, file, NULL, error)) if (!ostree_pack_file ((GOutputStream*)out, file, cancellable, error))
goto out; goto out;
if (!g_output_stream_close ((GOutputStream*)out, NULL, error)) if (!g_output_stream_close ((GOutputStream*)out, cancellable, error))
goto out; goto out;
} }
@ -939,13 +944,14 @@ ostree_repo_store_object_trusted (OstreeRepo *self,
OstreeObjectType objtype, OstreeObjectType objtype,
gboolean overwrite, gboolean overwrite,
gboolean *did_exist, gboolean *did_exist,
GCancellable *cancellable,
GError **error) GError **error)
{ {
OstreeRepoPrivate *priv = GET_PRIVATE (self); OstreeRepoPrivate *priv = GET_PRIVATE (self);
if (priv->archive && objtype == OSTREE_OBJECT_TYPE_FILE) if (priv->archive && objtype == OSTREE_OBJECT_TYPE_FILE)
return archive_file_trusted (self, file, checksum, overwrite, did_exist, error); return archive_file_trusted (self, file, checksum, overwrite, did_exist, cancellable, error);
else else
return link_object_trusted (self, file, checksum, objtype, overwrite, did_exist, error); return link_object_trusted (self, file, checksum, objtype, overwrite, did_exist, cancellable, error);
} }
gboolean gboolean
@ -979,7 +985,7 @@ ostree_repo_store_packfile (OstreeRepo *self,
if (!ostree_repo_store_object_trusted (self, tempfile, if (!ostree_repo_store_object_trusted (self, tempfile,
expected_checksum, expected_checksum,
objtype, objtype,
FALSE, did_exist, error)) FALSE, did_exist, NULL, error))
goto out; goto out;
ret = TRUE; ret = TRUE;
@ -1061,7 +1067,7 @@ import_commit (OstreeRepo *self,
g_checksum_get_string (root_metadata_checksum)); g_checksum_get_string (root_metadata_checksum));
g_variant_ref_sink (commit); g_variant_ref_sink (commit);
if (!import_gvariant_object (self, OSTREE_SERIALIZED_COMMIT_VARIANT, if (!import_gvariant_object (self, OSTREE_SERIALIZED_COMMIT_VARIANT,
commit, &ret_commit, error)) commit, &ret_commit, NULL, error))
goto out; goto out;
if (!ostree_repo_write_ref (self, NULL, branch, g_checksum_get_string (ret_commit), error)) if (!ostree_repo_write_ref (self, NULL, branch, g_checksum_get_string (ret_commit), error))
@ -1111,7 +1117,7 @@ import_directory_recurse (OstreeRepo *self,
GVariant *serialized_tree = NULL; GVariant *serialized_tree = NULL;
gpointer key, value; gpointer key, value;
if (!import_directory_meta (self, dir, NULL, &ret_metadata_checksum, error)) if (!import_directory_meta (self, dir, NULL, &ret_metadata_checksum, cancellable, error))
goto out; goto out;
dir_enum = g_file_enumerate_children ((GFile*)dir, OSTREE_GIO_FAST_QUERYINFO, dir_enum = g_file_enumerate_children ((GFile*)dir, OSTREE_GIO_FAST_QUERYINFO,
@ -1158,7 +1164,7 @@ import_directory_recurse (OstreeRepo *self,
goto out; goto out;
if (!ostree_repo_store_object_trusted (self, child, g_checksum_get_string (child_file_checksum), if (!ostree_repo_store_object_trusted (self, child, g_checksum_get_string (child_file_checksum),
OSTREE_OBJECT_TYPE_FILE, FALSE, &did_exist, error)) OSTREE_OBJECT_TYPE_FILE, FALSE, &did_exist, cancellable, error))
goto out; goto out;
g_hash_table_replace (file_checksums, g_strdup (name), g_hash_table_replace (file_checksums, g_strdup (name),
@ -1228,7 +1234,9 @@ import_directory_recurse (OstreeRepo *self,
builders_initialized = FALSE; builders_initialized = FALSE;
g_variant_ref_sink (serialized_tree); g_variant_ref_sink (serialized_tree);
if (!import_gvariant_object (self, OSTREE_SERIALIZED_TREE_VARIANT, serialized_tree, &ret_contents_checksum, error)) if (!import_gvariant_object (self, OSTREE_SERIALIZED_TREE_VARIANT,
serialized_tree, &ret_contents_checksum,
cancellable, error))
goto out; goto out;
*out_metadata_checksum = ret_metadata_checksum; *out_metadata_checksum = ret_metadata_checksum;

View File

@ -84,6 +84,7 @@ gboolean ostree_repo_store_object_trusted (OstreeRepo *self,
OstreeObjectType objtype, OstreeObjectType objtype,
gboolean overwrite, gboolean overwrite,
gboolean *did_exist, gboolean *did_exist,
GCancellable *cancellable,
GError **error); GError **error);
gboolean ostree_repo_resolve_rev (OstreeRepo *self, gboolean ostree_repo_resolve_rev (OstreeRepo *self,

View File

@ -115,6 +115,7 @@ object_iter_callback (OstreeRepo *repo,
objtype, objtype,
FALSE, FALSE,
&did_exist, &did_exist,
NULL,
&error)) &error))
goto out; goto out;
} }
@ -126,6 +127,7 @@ object_iter_callback (OstreeRepo *repo,
objtype, objtype,
FALSE, FALSE,
&did_exist, &did_exist,
NULL,
&error)) &error))
goto out; goto out;
} }