[gimp] plug-ins: add --progress=dot to work with newer wgets, and add ftp support
- From: Mikael Magnusson <mikachu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: add --progress=dot to work with newer wgets, and add ftp support
- Date: Mon, 4 Jul 2011 22:14:50 +0000 (UTC)
commit 520d8529120c38095a6053e6634d0039ce889ba4
Author: Mikael Magnusson <mikachu src gnome org>
Date: Tue Jul 5 00:13:13 2011 +0200
plug-ins: add --progress=dot to work with newer wgets, and add ftp support
Fixes bug 653974 - uri-backend-wget backend is broken
plug-ins/file-uri/uri-backend-wget.c | 61 +++++++++++++++++++++++++++++++++-
1 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/file-uri/uri-backend-wget.c b/plug-ins/file-uri/uri-backend-wget.c
index 56bf75b..20c2e46 100644
--- a/plug-ins/file-uri/uri-backend-wget.c
+++ b/plug-ins/file-uri/uri-backend-wget.c
@@ -121,7 +121,7 @@ uri_backend_load_image (const gchar *uri,
g_snprintf (timeout_str, sizeof (timeout_str), "%d", TIMEOUT);
execlp ("wget",
- "wget", "-v", "-e", "server-response=off", "-T", timeout_str,
+ "wget", "-v", "-e", "server-response=off", "--progress=dot", "-T", timeout_str,
uri, "-O", tmpname, NULL);
_exit (127);
}
@@ -130,6 +130,7 @@ uri_backend_load_image (const gchar *uri,
FILE *input;
gchar buf[BUFSIZE];
gboolean seen_resolve = FALSE;
+ gboolean seen_ftp = FALSE;
gboolean connected = FALSE;
gboolean redirect = FALSE;
gboolean file_found = FALSE;
@@ -181,6 +182,11 @@ uri_backend_load_image (const gchar *uri,
_("wget exited abnormally on URI '%s'"), uri);
return FALSE;
}
+ /* with an ftp url wget has a "=> `filename.foo" */
+ else if ( !seen_ftp && strstr (buf, "=> `"))
+ {
+ seen_ftp = TRUE;
+ }
DEBUG (buf);
@@ -232,6 +238,16 @@ uri_backend_load_image (const gchar *uri,
return FALSE;
}
+ /* on successful ftp login wget prints a "Logged in" message */
+ else if ( seen_ftp && !strstr(buf, "Logged in!"))
+ {
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("A network error occurred: %s"), buf);
+
+ DEBUG (buf);
+
+ return FALSE;
+ }
else if (strstr (buf, "302 Found"))
{
DEBUG (buf);
@@ -245,6 +261,37 @@ uri_backend_load_image (const gchar *uri,
DEBUG (buf);
+ /* for an ftp session wget has extra output*/
+ ftp_session:
+ if (seen_ftp)
+ {
+ if (fgets (buf, sizeof (buf), input) == NULL)
+ {
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("A network error occurred: %s"), buf);
+
+ DEBUG (buf);
+
+ return FALSE;
+ }
+ /* if there is no size output file does not exist on server */
+ else if (strstr (buf, "==> SIZE") && strstr (buf, "... done"))
+ {
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("wget exited abnormally on URI '%s'"), uri);
+
+ DEBUG (buf);
+
+ return FALSE;
+ }
+ /* while no PASV line we eat other messages */
+ else if (!strstr (buf, "==> PASV"))
+ {
+ DEBUG (buf);
+ goto ftp_session;
+ }
+ }
+
/* The fifth line is either the length of the file or an error */
if (fgets (buf, sizeof (buf), input) == NULL)
{
@@ -295,6 +342,18 @@ uri_backend_load_image (const gchar *uri,
size = 0;
}
+ /* on http sessions wget has "Saving to: ..." */
+ if (!seen_ftp)
+ {
+ if (fgets (buf, sizeof (buf), input) == NULL)
+ {
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("wget exited abnormally on URI '%s'"), uri);
+
+ return FALSE;
+ }
+ }
+
/* Start the actual download... */
if (size > 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]