Skip to content

add check if libmagic fails#4273

Merged
aadland6 merged 2 commits intomainfrom
fix-filetype-error
Mar 3, 2026
Merged

add check if libmagic fails#4273
aadland6 merged 2 commits intomainfrom
fix-filetype-error

Conversation

@aadland6
Copy link
Contributor

@aadland6 aadland6 commented Mar 3, 2026

No description provided.

# -- on some environments libmagic can return a generic/unhelpful MIME-type
# -- like octet-stream") for files that the `filetype` package identify.
# -- when that happens we retry using `filetype` `FileType.UNK` results.
if LIBMAGIC_AVAILABLE:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only need to call this when file_type == FileType.UNK and LIBMAGIC_AVAILABLE, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - only cases where libmagic is already available but failed to get the right file

  1. mime_type is not None (otherwise the function already returned None), and

  2. FileType.from_mime_type(mime_type) returned FileType.UNK, and

  3. LIBMAGIC_AVAILABLE is True.

@aadland6 aadland6 requested a review from badGarnet March 3, 2026 17:31
@aadland6 aadland6 added this pull request to the merge queue Mar 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 3, 2026
@aadland6 aadland6 added this pull request to the merge queue Mar 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 3, 2026
@aadland6 aadland6 added this pull request to the merge queue Mar 3, 2026
Merged via the queue into main with commit ac14f57 Mar 3, 2026
57 checks passed
@aadland6 aadland6 deleted the fix-filetype-error branch March 3, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants