[gimp] app: fix GEX installation with warning while decompressing.



commit c928fda8ff4fe3a941b67c78977cf0417578ce69
Author: Jehan <jehan girinstud io>
Date:   Wed Oct 12 00:04:18 2022 +0200

    app: fix GEX installation with warning while decompressing.
    
    There is not only the ARCHIVE_OK and ARCHIVE_FATAL cases. There are also
    ARCHIVE_WARN cases which should not break the installation (I think?). Since I
    still want to pass the warning over to extension developers, I am printing it to
    stderr.
    
    As an additional fix, prevent such a warning when installing an extension over
    itself. In such case, it looks like the archive_entry_size() would be 0, which
    was triggering some "Writing to Empty File" warning.

 app/file-data/file-data-gex.c | 52 ++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 20 deletions(-)
---
diff --git a/app/file-data/file-data-gex.c b/app/file-data/file-data-gex.c
index 5f8a75e55b..b301de6df2 100644
--- a/app/file-data/file-data-gex.c
+++ b/app/file-data/file-data-gex.c
@@ -405,7 +405,7 @@ file_gex_decompress (GFile   *file,
                   g_free (path);
 
                   r = archive_write_header (ext, entry);
-                  if (r < ARCHIVE_OK)
+                  if (r < ARCHIVE_WARN)
                     {
                       *error = g_error_new (GIMP_EXTENSION_ERROR, GIMP_EXTENSION_FAILED,
                                             _("Fatal error when uncompressing GIMP extension '%s': %s"),
@@ -414,28 +414,40 @@ file_gex_decompress (GFile   *file,
                       break;
                     }
 
-                  while (TRUE)
+                  if (archive_entry_size (entry) > 0)
                     {
-                      r = archive_read_data_block (a, &buffer, &size, &offset);
-                      if (r == ARCHIVE_FATAL)
+                      while (TRUE)
                         {
-                          *error = g_error_new (GIMP_EXTENSION_ERROR, GIMP_EXTENSION_FAILED,
-                                                _("Fatal error when uncompressing GIMP extension '%s': %s"),
-                                                gimp_file_get_utf8_name (file),
-                                                archive_error_string (a));
-                          break;
-                        }
-                      else if (r == ARCHIVE_EOF)
-                        break;
+                          r = archive_read_data_block (a, &buffer, &size, &offset);
+                          if (r == ARCHIVE_EOF)
+                            {
+                              break;
+                            }
+                          else if (r < ARCHIVE_WARN)
+                            {
+                              *error = g_error_new (GIMP_EXTENSION_ERROR, GIMP_EXTENSION_FAILED,
+                                                    _("Fatal error when uncompressing GIMP extension '%s': 
%s"),
+                                                    gimp_file_get_utf8_name (file),
+                                                    archive_error_string (a));
+                              break;
+                            }
 
-                      r = archive_write_data_block (ext, buffer, size, offset);
-                      if (r < ARCHIVE_OK)
-                        {
-                          *error = g_error_new (GIMP_EXTENSION_ERROR, GIMP_EXTENSION_FAILED,
-                                                _("Fatal error when uncompressing GIMP extension '%s': %s"),
-                                                gimp_file_get_utf8_name (file),
-                                                archive_error_string (ext));
-                          break;
+                          r = archive_write_data_block (ext, buffer, size, offset);
+                          if (r == ARCHIVE_WARN)
+                            {
+                              g_printerr (_("Warning when uncompressing GIMP extension '%s': %s\n"),
+                                          gimp_file_get_utf8_name (file),
+                                          archive_error_string (ext));
+                              break;
+                            }
+                          else if (r < ARCHIVE_OK)
+                            {
+                              *error = g_error_new (GIMP_EXTENSION_ERROR, GIMP_EXTENSION_FAILED,
+                                                    _("Fatal error when uncompressing GIMP extension '%s': 
%s"),
+                                                    gimp_file_get_utf8_name (file),
+                                                    archive_error_string (ext));
+                              break;
+                            }
                         }
                     }
                   if (*error)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]