feat: add --mime-types option
Resolves #1073
Adds the new option --mime-types, which when enabled will read file contents to get the MIME type of a file to determine its file type as a fallback, if the file type could not be determined otherwise.
MIME type overrides can also be added in theme.yml.
Quick performance test using the command eza -laT --icons on a directory with ~300k (nested) files of various types, total size ~8GB on a reasonably fast SSD. As expected there is a noticeable runtime impact if the option is enabled, but that is why its disabled by default.
main:
real 0m2.893s
user 0m5.036s
sys 0m3.522s
PR (default behaviour, option disabled):
real 0m2.931s
user 0m5.317s
sys 0m3.543s
PR (option enabled):
real 0m6.635s
user 0m9.154s
sys 0m4.226s
Another test with a very slow NFSv3 mount, ~150k files and ~1.4TB of again pretty much all types of files. Here the runtime impact is much more pronounced, however this should be pretty much the worst case scenario.
main:
real 0m29.964s
user 0m3.277s
sys 0m4.519s
PR (default behaviour, option disabled):
real 0m28.753s
user 0m3.498s
sys 0m4.251s
PR (option enabled):
real 4m5.673s
user 0m9.595s
sys 0m8.184s
The tests on the SSD are the fastest measured in 10 runs, the tests on the network mount the fastest out of 4 runs.