diff options
author | Đoàn Trần Công Danh <[email protected]> | 2020-12-15 23:35:36 +0700 |
---|---|---|
committer | Victor Kareh <[email protected]> | 2023-03-22 07:28:43 -0400 |
commit | 4ee39ab04260179144ebb9ac7160df79a5b1e6fc (patch) | |
tree | 4c112d1287b9b978de8935ce18b6af2c9bb0220c /src | |
parent | a36c201627e687e99d1c8b8f3b32e864cede7662 (diff) | |
download | engrampa-4ee39ab04260179144ebb9ac7160df79a5b1e6fc.tar.bz2 engrampa-4ee39ab04260179144ebb9ac7160df79a5b1e6fc.tar.xz |
zstd: support both old and new mime type
As of it's now, we're supporting zstd {,de}compression with specific
mime type that was reported by libmagic as configure time. Thus, the
built binaries is not correct after upgrading file-devel after
configure. In addition, this configure's time hard-coded value prevent
our users from partial upgrade.
Let's accept both mime types reported by both old and new file-devel.
For the mapping between file extensions and mime types, let's choose the
new mime value.
Diffstat (limited to 'src')
-rw-r--r-- | src/fr-command-cfile.c | 18 | ||||
-rw-r--r-- | src/fr-init.c | 5 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/fr-command-cfile.c b/src/fr-command-cfile.c index 647dbe3..52b023a 100644 --- a/src/fr-command-cfile.c +++ b/src/fr-command-cfile.c @@ -296,7 +296,8 @@ fr_command_cfile_add (FrCommand *comm, compressed_filename = g_strconcat (filename, ".rz", NULL); } - else if (is_mime_type (comm->mime_type, ZSTD_MIME_TYPE)) { + else if (is_mime_type (comm->mime_type, "application/zstd") + || is_mime_type (comm->mime_type, "application/x-zstd")) { fr_process_begin_command (comm->process, "zstd"); fr_process_set_working_dir (comm->process, temp_dir); fr_process_add_arg (comm->process, filename); @@ -439,7 +440,8 @@ fr_command_cfile_extract (FrCommand *comm, fr_process_end_command (comm->process); } - else if (is_mime_type (comm->mime_type, ZSTD_MIME_TYPE)) { + else if (is_mime_type (comm->mime_type, "application/zstd") + || is_mime_type (comm->mime_type, "application/x-zstd")) { fr_process_begin_command (comm->process, "zstd"); fr_process_add_arg (comm->process, "-f"); fr_process_add_arg (comm->process, "-d"); @@ -508,7 +510,8 @@ fr_command_cfile_test (FrCommand *comm) else if (is_mime_type (comm->mime_type, "application/x-lzop")) { compress_cmd = "lzop"; } - else if (is_mime_type (comm->mime_type, ZSTD_MIME_TYPE)) { + else if (is_mime_type (comm->mime_type, "application/zstd") + || is_mime_type (comm->mime_type, "application/x-zstd")) { compress_cmd = "zstd"; fr_process_begin_command (comm->process, compress_cmd); fr_process_add_arg (comm->process, "-v"); @@ -535,7 +538,8 @@ const char *cfile_mime_type[] = { "application/x-gzip", "application/x-lzop", "application/x-rzip", "application/x-xz", - ZSTD_MIME_TYPE, + "application/zstd", + "application/x-zstd", NULL }; static const char ** @@ -590,7 +594,8 @@ fr_command_cfile_get_capabilities (FrCommand *comm, if (is_program_available ("rzip", check_command)) capabilities |= FR_COMMAND_CAN_READ_WRITE; } - else if (is_mime_type (mime_type, ZSTD_MIME_TYPE)) { + else if (is_mime_type (mime_type, "application/zstd") + || is_mime_type (mime_type, "application/x-zstd")) { if (is_program_available ("zstd", check_command)) capabilities |= FR_COMMAND_CAN_READ_WRITE; } @@ -631,7 +636,8 @@ fr_command_cfile_get_packages (FrCommand *comm, return PACKAGES ("lzop"); else if (is_mime_type (mime_type, "application/x-rzip")) return PACKAGES ("rzip"); - else if (is_mime_type (mime_type, ZSTD_MIME_TYPE)) + else if (is_mime_type (mime_type, "application/zstd") + || is_mime_type (mime_type, "application/x-zstd")) return PACKAGES ("zstd"); return NULL; diff --git a/src/fr-init.c b/src/fr-init.c index 256e13e..c018bfa 100644 --- a/src/fr-init.c +++ b/src/fr-init.c @@ -109,7 +109,8 @@ FrMimeTypeDescription mime_type_desc[] = { { "application/x-xz", ".xz", N_("Xz compressed file"), 0 }, { "application/x-xz-compressed-tar", ".tar.xz", N_("Tar compressed with xz"), 0 }, { "application/x-zoo", ".zoo", N_("Zoo"), 0 }, - { ZSTD_MIME_TYPE, ".zst", N_("Zstandard compressed file"), 0 }, + { "application/zstd", ".zst", N_("Zstandard compressed file"), 0 }, + { "application/x-zstd", ".zst", N_("Zstandard compressed file"), 0 }, { "application/x-zstd-compressed-tar", ".tar.zst", N_("Tar compressed with zstd"), 0 }, { "application/zip", ".zip", N_("Zip"), 0 }, { NULL, NULL, NULL, 0 } @@ -184,7 +185,7 @@ FrExtensionType file_ext_type[] = { { ".Z", "application/x-compress" }, { ".zip", "application/zip" }, { ".zoo", "application/x-zoo" }, - { ".zst", ZSTD_MIME_TYPE }, + { ".zst", "application/zstd" }, { NULL, NULL } }; |