mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-10 05:18:30 +03:00
pull: Make fetcher work for file:/// URIs too
Even if very suboptimally, for now; we copy the files, then copy them again. The obvious long term plan is to merge pull-local and pull together, but truly optimizing that requires the pull code to know how to use the OstreeRepo APIs when operating on local repositories (as pull-local does), rather than assuming the remote is an archive-z fetched over HTTP.
This commit is contained in:
parent
dc0f3c3dcb
commit
a93f2b8d16
@ -189,49 +189,52 @@ on_request_sent (GObject *object,
|
||||
{
|
||||
OstreeFetcherPendingURI *pending = user_data;
|
||||
GError *local_error = NULL;
|
||||
ot_lobj SoupMessage *msg = NULL;
|
||||
gs_unref_object SoupMessage *msg = NULL;
|
||||
GOutputStreamSpliceFlags flags = G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET;
|
||||
|
||||
pending->request_body = soup_request_send_finish ((SoupRequest*) object,
|
||||
result, &local_error);
|
||||
msg = soup_request_http_get_message ((SoupRequestHTTP*) object);
|
||||
|
||||
if (!pending->request_body)
|
||||
{
|
||||
pending->state = OSTREE_FETCHER_STATE_COMPLETE;
|
||||
g_simple_async_result_take_error (pending->result, local_error);
|
||||
g_simple_async_result_complete (pending->result);
|
||||
return;
|
||||
}
|
||||
else if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
|
||||
|
||||
if (SOUP_IS_REQUEST_HTTP (object))
|
||||
{
|
||||
g_set_error (&local_error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Server returned status %u: %s",
|
||||
msg->status_code, soup_status_get_phrase (msg->status_code));
|
||||
g_simple_async_result_take_error (pending->result, local_error);
|
||||
g_simple_async_result_complete (pending->result);
|
||||
}
|
||||
else
|
||||
{
|
||||
GOutputStreamSpliceFlags flags = G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET;
|
||||
|
||||
pending->state = OSTREE_FETCHER_STATE_DOWNLOADING;
|
||||
|
||||
pending->content_length = soup_request_get_content_length (pending->request);
|
||||
|
||||
/* TODO - make this async */
|
||||
if (!ostree_create_temp_regular_file (pending->self->tmpdir,
|
||||
NULL, NULL,
|
||||
&pending->tmpfile,
|
||||
&pending->out_stream,
|
||||
NULL, &local_error))
|
||||
msg = soup_request_http_get_message ((SoupRequestHTTP*) object);
|
||||
if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
|
||||
{
|
||||
g_set_error (&local_error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Server returned status %u: %s",
|
||||
msg->status_code, soup_status_get_phrase (msg->status_code));
|
||||
g_simple_async_result_take_error (pending->result, local_error);
|
||||
g_simple_async_result_complete (pending->result);
|
||||
return;
|
||||
}
|
||||
|
||||
g_output_stream_splice_async (pending->out_stream, pending->request_body, flags, G_PRIORITY_DEFAULT,
|
||||
pending->cancellable, on_splice_complete, pending);
|
||||
}
|
||||
|
||||
pending->state = OSTREE_FETCHER_STATE_DOWNLOADING;
|
||||
|
||||
pending->content_length = soup_request_get_content_length (pending->request);
|
||||
|
||||
/* TODO - make this async */
|
||||
if (!ostree_create_temp_regular_file (pending->self->tmpdir,
|
||||
NULL, NULL,
|
||||
&pending->tmpfile,
|
||||
&pending->out_stream,
|
||||
NULL, &local_error))
|
||||
{
|
||||
g_simple_async_result_take_error (pending->result, local_error);
|
||||
g_simple_async_result_complete (pending->result);
|
||||
return;
|
||||
}
|
||||
|
||||
g_output_stream_splice_async (pending->out_stream, pending->request_body, flags, G_PRIORITY_DEFAULT,
|
||||
pending->cancellable, on_splice_complete, pending);
|
||||
}
|
||||
|
||||
void
|
||||
@ -255,9 +258,12 @@ ostree_fetcher_request_uri_async (OstreeFetcher *self,
|
||||
g_assert_no_error (local_error);
|
||||
|
||||
pending->refcount++;
|
||||
g_hash_table_insert (self->message_to_request,
|
||||
soup_request_http_get_message ((SoupRequestHTTP*)pending->request),
|
||||
pending);
|
||||
if (SOUP_IS_REQUEST_HTTP (pending->request))
|
||||
{
|
||||
g_hash_table_insert (self->message_to_request,
|
||||
soup_request_http_get_message ((SoupRequestHTTP*)pending->request),
|
||||
pending);
|
||||
}
|
||||
|
||||
pending->result = g_simple_async_result_new ((GObject*) self,
|
||||
callback, user_data,
|
||||
|
@ -39,6 +39,8 @@ cd ${test_tmpdir}
|
||||
${CMD_PREFIX} ostree --repo=repo2 checkout test2 test2-checkout-from-local-clone
|
||||
cd test2-checkout-from-local-clone
|
||||
assert_file_has_content baz/cow moo
|
||||
cd ${test_tmpdir}
|
||||
rm repo2 -rf
|
||||
echo "ok local clone checkout"
|
||||
|
||||
$OSTREE checkout -U test2 checkout-user-test2
|
||||
@ -64,3 +66,12 @@ echo "ok cat-file"
|
||||
cd ${test_tmpdir}
|
||||
$OSTREE fsck
|
||||
echo "ok fsck"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
mkdir repo2
|
||||
${CMD_PREFIX} ostree --repo=repo2 init
|
||||
${CMD_PREFIX} ostree --repo=repo2 remote add aremote file://$(pwd)/repo test2
|
||||
ostree --repo=repo2 pull aremote
|
||||
ostree --repo=repo2 rev-parse aremote/test2
|
||||
ostree --repo=repo2 fsck
|
||||
echo "ok pull with from file:/// uri"
|
||||
|
Loading…
Reference in New Issue
Block a user