summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2023-06-14 14:15:38 +0200
committermouse <[email protected]>2023-06-15 11:31:03 +0800
commit79c9b8ee20cdf11c69dde173c5f04d51d5f8c778 (patch)
treebee237035428f367542e657bdf839cc7f1acff77 /src
parent8e33e604d87e90bda3cc748bc1627c164d72a16c (diff)
downloadengrampa-79c9b8ee20cdf11c69dde173c5f04d51d5f8c778.tar.bz2
engrampa-79c9b8ee20cdf11c69dde173c5f04d51d5f8c778.tar.xz
Fix MIME detection logic from #490
A blooper has been made there: * if ENABLE_MIME is set, the intention was to try, in order: magic, content, filename; but it was made filename, content, magic (which was the same as before the changes); * if ENABLE_MIME is not set, the intention was to try, in order: filename, content, magic; but it has been made magic, content, magic (notice the duplicate, and the missing "filename"). This probably doesn't change much in the wild as magic is gonna work most of the time, but it's especially problematic that the non-libmagic case doesn't have the filename test. Anyway, fix this so the code is consistent, and we retain the behavior for the non-libmagic case, and have the new expected one for the libmagic case.
Diffstat (limited to 'src')
-rw-r--r--src/fr-archive.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/fr-archive.c b/src/fr-archive.c
index f4ccefe..18c700c 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -1102,16 +1102,22 @@ load_local_archive (FrArchive *archive,
old_command = archive->command;
+ /* With libmagic, give priority to magic match, and fall back on filename
+ * match. Do it the other way around if we don't have libmagic. */
#if ENABLE_MAGIC
- mime_type = get_mime_type_from_filename (archive->local_copy);
-#else
mime_type = get_mime_type_from_magic_numbers (archive->local_copy);
+#else
+ mime_type = get_mime_type_from_filename (archive->local_copy);
#endif
if (! create_command_to_load_archive (archive, mime_type)) {
mime_type = get_mime_type_from_content (archive->local_copy);
if (! create_command_to_load_archive (archive, mime_type)) {
+#if ENABLE_MAGIC
+ mime_type = get_mime_type_from_filename (archive->local_copy);
+#else
mime_type = get_mime_type_from_magic_numbers (archive->local_copy);
+#endif
if (! create_command_to_load_archive (archive, mime_type)) {
archive->command = old_command;
archive->content_type = mime_type;