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,29 +189,33 @@ on_request_sent (GObject *object,
|
||||||
{
|
{
|
||||||
OstreeFetcherPendingURI *pending = user_data;
|
OstreeFetcherPendingURI *pending = user_data;
|
||||||
GError *local_error = NULL;
|
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,
|
pending->request_body = soup_request_send_finish ((SoupRequest*) object,
|
||||||
result, &local_error);
|
result, &local_error);
|
||||||
msg = soup_request_http_get_message ((SoupRequestHTTP*) object);
|
|
||||||
|
|
||||||
if (!pending->request_body)
|
if (!pending->request_body)
|
||||||
{
|
{
|
||||||
pending->state = OSTREE_FETCHER_STATE_COMPLETE;
|
pending->state = OSTREE_FETCHER_STATE_COMPLETE;
|
||||||
g_simple_async_result_take_error (pending->result, local_error);
|
g_simple_async_result_take_error (pending->result, local_error);
|
||||||
g_simple_async_result_complete (pending->result);
|
g_simple_async_result_complete (pending->result);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
|
|
||||||
|
if (SOUP_IS_REQUEST_HTTP (object))
|
||||||
|
{
|
||||||
|
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,
|
g_set_error (&local_error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
"Server returned status %u: %s",
|
"Server returned status %u: %s",
|
||||||
msg->status_code, soup_status_get_phrase (msg->status_code));
|
msg->status_code, soup_status_get_phrase (msg->status_code));
|
||||||
g_simple_async_result_take_error (pending->result, local_error);
|
g_simple_async_result_take_error (pending->result, local_error);
|
||||||
g_simple_async_result_complete (pending->result);
|
g_simple_async_result_complete (pending->result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
GOutputStreamSpliceFlags flags = G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET;
|
|
||||||
|
|
||||||
pending->state = OSTREE_FETCHER_STATE_DOWNLOADING;
|
pending->state = OSTREE_FETCHER_STATE_DOWNLOADING;
|
||||||
|
|
||||||
|
|
@ -231,7 +235,6 @@ on_request_sent (GObject *object,
|
||||||
|
|
||||||
g_output_stream_splice_async (pending->out_stream, pending->request_body, flags, G_PRIORITY_DEFAULT,
|
g_output_stream_splice_async (pending->out_stream, pending->request_body, flags, G_PRIORITY_DEFAULT,
|
||||||
pending->cancellable, on_splice_complete, pending);
|
pending->cancellable, on_splice_complete, pending);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -255,9 +258,12 @@ ostree_fetcher_request_uri_async (OstreeFetcher *self,
|
||||||
g_assert_no_error (local_error);
|
g_assert_no_error (local_error);
|
||||||
|
|
||||||
pending->refcount++;
|
pending->refcount++;
|
||||||
|
if (SOUP_IS_REQUEST_HTTP (pending->request))
|
||||||
|
{
|
||||||
g_hash_table_insert (self->message_to_request,
|
g_hash_table_insert (self->message_to_request,
|
||||||
soup_request_http_get_message ((SoupRequestHTTP*)pending->request),
|
soup_request_http_get_message ((SoupRequestHTTP*)pending->request),
|
||||||
pending);
|
pending);
|
||||||
|
}
|
||||||
|
|
||||||
pending->result = g_simple_async_result_new ((GObject*) self,
|
pending->result = g_simple_async_result_new ((GObject*) self,
|
||||||
callback, user_data,
|
callback, user_data,
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ cd ${test_tmpdir}
|
||||||
${CMD_PREFIX} ostree --repo=repo2 checkout test2 test2-checkout-from-local-clone
|
${CMD_PREFIX} ostree --repo=repo2 checkout test2 test2-checkout-from-local-clone
|
||||||
cd test2-checkout-from-local-clone
|
cd test2-checkout-from-local-clone
|
||||||
assert_file_has_content baz/cow moo
|
assert_file_has_content baz/cow moo
|
||||||
|
cd ${test_tmpdir}
|
||||||
|
rm repo2 -rf
|
||||||
echo "ok local clone checkout"
|
echo "ok local clone checkout"
|
||||||
|
|
||||||
$OSTREE checkout -U test2 checkout-user-test2
|
$OSTREE checkout -U test2 checkout-user-test2
|
||||||
|
|
@ -64,3 +66,12 @@ echo "ok cat-file"
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
$OSTREE fsck
|
$OSTREE fsck
|
||||||
echo "ok 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