Re: new mime detection approach



On Thu, 2004-01-15 at 03:57, Alexander Larsson wrote:
> Basically, we use regexp detection by default, and if that fails (i.e.
> due to no extension) we fall back to magic sniffing. However, for
> important uses (such as file properties, file launching etc) we force
> sniffing. We also sniff files when they are selected the first time. 
> 
> This has a couple of interesting features:
> 
> * Allows "unix-style" no extensions files to work as before
> * Does minimal I/O for directories where files have extensions,
> resulting in better performance and less HD wear.
> * Never moves around icons without the user explicitly doing something
> with them, meaning clicks are deterministic. (i.e. the icon won't move
> right before you click on it because a background sniff changed the type
> of something and relayouted the folder.)
> * Only sniffs files on some explicit action, minimizing e.g. network
> bandwidth use, while still never being fooled by wrong extensions for
> important operations.

I have no idea how the magic mime-type detection code works, but would
it be made faster by using the extensions of a file as a hint? ie. if
you are trying to determine the type of a file with .jpg extension,
first check the JPEG magic entry? This should only involve reading the
first few characters of the file.

By using extensions to prioritise the mime-type detections, we would
also fix people's problems with mis-detection of filetypes. For example,
if I rename a .sh file to .txt, then Nautilus would recognise it as text
because it only contains ASCII characters and the 'text' magic entry was
tested first. As another example, if I renamed a JPEG file to .txt (and
Nautilus checks and finds that it contains binary characters), then
Nautilus would realise that a mistake was made by the user and instead
recognise it as JPEG.

It would also remove the problem (mentioned elsewhere) where
thumbnailable filetypes aren't thumbnailed until they're clicked on.

Just my two cents.

-- 
Peter Harvey.
Mostly Quiet.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]