[libgdata/wip/oholy/authorization-errors] core: Always refresh authorization when creating streams
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/wip/oholy/authorization-errors] core: Always refresh authorization when creating streams
- Date: Tue, 21 Jan 2020 13:07:34 +0000 (UTC)
commit c21fd9a7883a08e12e10327ecd066b4980085514
Author: Ondrej Holy <oholy redhat com>
Date: Mon Jan 20 13:51:20 2020 +0100
core: Always refresh authorization when creating streams
Non-resumable upload streams quite often fail with authorization errors
as we are probably hitting some limits. The only way currently to deal
with them is to refresh authorization manually and upload everything
again as it is not possible to resume the transfer. This is big issue
for streaming operations provided by GVfs. I have made several tests
and realized that if we explicitely refresh the authorization before
the transfer, then those authorization errors doesn't occur. So let's
always refresh the authorization when constructing the streams and do
the same for upload streams as well as they are also affected. In theory,
the resumable streams could solve this better, however they currently
require content size to be specified at the beginning, which is not
usable for the streaming operations in GVfs.
Fixes: https://gitlab.gnome.org/GNOME/libgdata/issues/23
gdata/gdata-download-stream.c | 20 ++++++++++++++++++++
gdata/gdata-upload-stream.c | 14 ++++++++++++++
2 files changed, 34 insertions(+)
---
diff --git a/gdata/gdata-download-stream.c b/gdata/gdata-download-stream.c
index 5bfd7048..67e1f0ab 100644
--- a/gdata/gdata-download-stream.c
+++ b/gdata/gdata-download-stream.c
@@ -337,6 +337,7 @@ gdata_download_stream_constructor (GType type, guint n_construct_params, GObject
{
GDataDownloadStreamPrivate *priv;
GDataServiceClass *klass;
+ GDataAuthorizer *authorizer;
GObject *object;
SoupURI *_uri;
@@ -355,6 +356,12 @@ gdata_download_stream_constructor (GType type, guint n_construct_params, GObject
priv->cancellable = g_cancellable_new ();
priv->network_cancellable_id = g_cancellable_connect (priv->cancellable, (GCallback)
cancellable_cancel_cb, priv->network_cancellable, NULL);
+ /* FIXME: Refresh authorization before building message in order to prevent authorization errors
during transfer.
+ * See: https://gitlab.gnome.org/GNOME/libgdata/issues/23 */
+ authorizer = gdata_service_get_authorizer (priv->service);
+ if (authorizer)
+ gdata_authorizer_refresh_authorization (authorizer, priv->cancellable, NULL);
+
/* Build the message. The URI must be HTTPS. */
_uri = soup_uri_new (priv->download_uri);
soup_uri_set_port (_uri, _gdata_service_get_https_port ());
@@ -855,11 +862,24 @@ static gpointer
download_thread (GDataDownloadStream *self)
{
GDataDownloadStreamPrivate *priv = self->priv;
+ GDataAuthorizer *authorizer;
g_object_ref (self);
g_assert (priv->network_cancellable != NULL);
+ /* FIXME: Refresh authorization before building message in order to prevent authorization errors
during transfer.
+ * See: https://gitlab.gnome.org/GNOME/libgdata/issues/23 */
+ authorizer = gdata_service_get_authorizer (priv->service);
+ if (authorizer) {
+ g_autoptr(GError) error = NULL;
+
+ gdata_authorizer_refresh_authorization (authorizer, priv->cancellable, &error);
+ if (error != NULL)
+ g_debug ("Error returned when refreshing authorization: %s\n", error->message);
+ else
+ gdata_authorizer_process_request (authorizer, priv->authorization_domain,
priv->message);
+ }
/* Connect to the got-headers signal so we can notify clients of the values of content-type and
content-length */
g_signal_connect (priv->message, "got-headers", (GCallback) got_headers_cb, self);
g_signal_connect (priv->message, "got-chunk", (GCallback) got_chunk_cb, self);
diff --git a/gdata/gdata-upload-stream.c b/gdata/gdata-upload-stream.c
index 85807fec..fb5ad214 100644
--- a/gdata/gdata-upload-stream.c
+++ b/gdata/gdata-upload-stream.c
@@ -1147,9 +1147,23 @@ static gpointer
upload_thread (GDataUploadStream *self)
{
GDataUploadStreamPrivate *priv = self->priv;
+ GDataAuthorizer *authorizer;
g_assert (priv->cancellable != NULL);
+ /* FIXME: Refresh authorization before building message in order to prevent authorization errors
during transfer.
+ * See: https://gitlab.gnome.org/GNOME/libgdata/issues/23 */
+ authorizer = gdata_service_get_authorizer (priv->service);
+ if (authorizer) {
+ g_autoptr(GError) error = NULL;
+
+ gdata_authorizer_refresh_authorization (authorizer, priv->cancellable, &error);
+ if (error != NULL)
+ g_debug ("Error returned when refreshing authorization: %s\n", error->message);
+ else
+ gdata_authorizer_process_request (authorizer, priv->authorization_domain,
priv->message);
+ }
+
while (TRUE) {
GDataServiceClass *klass;
gulong wrote_headers_signal, wrote_body_data_signal;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]