mirror of https://github.com/GNOME/gimp.git
plug-ins: add --progress=dot to work with newer wgets, and add ftp support
Fixes bug 653974 - uri-backend-wget backend is broken
This commit is contained in:
parent
14420e6cc5
commit
520d852912
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue