]> www.fi.muni.cz Git - evince.git/commitdiff
Make sure to fill in @error on failure. Also, since this is exported in
authorChristian Persch <chpe@src.gnome.org>
Sun, 15 Feb 2009 13:51:53 +0000 (13:51 +0000)
committerChristian Persch <chpe@src.gnome.org>
Sun, 15 Feb 2009 13:51:53 +0000 (13:51 +0000)
* libdocument/ev-file-helpers.c: (compression_run): Make sure to fill
in @error on failure. Also, since this is exported in public APIs,
cope with the passed-in GError** being NULL.

svn path=/trunk/; revision=3442

ChangeLog
libdocument/ev-file-helpers.c

index 135e5a167e1ea3dd033f1e0fe3556c9863e100ed..4a0fcf902688ed0df52d20ca1009eb247ba88c03 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-14  Christian Persch  <chpe@gnome.org>
+
+       * libdocument/ev-file-helpers.c: (compression_run): Make sure to fill
+       in @error on failure. Also, since this is exported in public APIs,
+       cope with the passed-in GError** being NULL.
+
 2009-02-13  Christian Persch  <chpe@gnome.org>
 
        * libdocument/ev-file-helpers.c: (get_mime_type_from_uri): NULL
index 2546fe700d4282ebc6902c00a931a280b520535d..6a3d2fa019e422943cb901cb26fe5c46e3c2fbf9 100644 (file)
@@ -315,15 +315,22 @@ compression_run (const gchar       *uri,
        gchar *filename, *filename_dst;
        gchar *cmd;
        gint   fd, pout;
+       GError *err = NULL;
 
        if (type == EV_COMPRESSION_NONE)
                return NULL;
 
        cmd = g_find_program_in_path ((type == EV_COMPRESSION_BZIP2) ? BZIPCOMMAND : GZIPCOMMAND);
-       if (!cmd)
+       if (!cmd) {
+               /* FIXME: better error codes! */
+               /* FIXME: i18n later */
+               g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                            "Failed to find the \"%s\" command in the search path.",
+                            type == EV_COMPRESSION_BZIP2 ? BZIPCOMMAND : GZIPCOMMAND);
                return NULL;
+       }
 
-       filename = g_filename_from_uri (uri, NULL, NULL);
+       filename = g_filename_from_uri (uri, NULL, error);
        if (!filename) {
                g_free (cmd);
                return NULL;
@@ -332,9 +339,16 @@ compression_run (const gchar       *uri,
        filename_dst = g_build_filename (ev_tmp_dir (), "evinceXXXXXX", NULL);
        fd = g_mkstemp (filename_dst);
        if (fd < 0) {
+               int errsv = errno;
+
                g_free (cmd);
                g_free (filename);
                g_free (filename_dst);
+
+               g_set_error (error, G_IO_ERROR,
+                            g_io_error_from_errno (errsv),
+                            "Error creating a temporary file: %s",
+                            g_strerror (errsv));
                return NULL;
        }
 
@@ -346,7 +360,7 @@ compression_run (const gchar       *uri,
        if (g_spawn_async_with_pipes (NULL, argv, NULL,
                                      G_SPAWN_STDERR_TO_DEV_NULL,
                                      NULL, NULL, NULL,
-                                     NULL, &pout, NULL, error)) {
+                                     NULL, &pout, NULL, &err)) {
                GIOChannel *in, *out;
                gchar buf[BUFFER_SIZE];
                GIOStatus read_st, write_st;
@@ -380,8 +394,10 @@ compression_run (const gchar       *uri,
 
        close (fd);
 
-       if (*error == NULL) {
-               uri_dst = g_filename_to_uri (filename_dst, NULL, NULL);
+       if (err) {
+               g_propagate_error (error, err);
+       } else {
+               uri_dst = g_filename_to_uri (filename_dst, NULL, error);
        }
 
        g_free (cmd);