Fix filetype check.

Created a new PR against staging and ready to test.

Revive #2743 by @nonumber