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.
This commit is contained in:
Jehan 2022-10-12 00:04:18 +02:00
parent 5df4875c88
commit c928fda8ff
1 changed files with 32 additions and 20 deletions

View File

@ -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)