Fix crashes that could occur when detecting file mimetypes.

Review Request #14229 — Created Nov. 5, 2024 and updated — Latest diff uploaded

Information

RBTools
release-5.x

Reviewers

This change mirrors a similar fix that we recently did for Review Board.
This fixes two issues with RBTools' MIME-type detection:

  1. Some versions of Python break if you try to close an already-closed
    pipe, and this had happened on one customer's machine. file may
    close the input stream once it's read enough data to make a
    determination, and our attempt to close would then fail.

  2. Errors executing or communicating with file would crash.

Ran unit tests.

Commits

Files