Opened 42 hours ago
Last modified 2 hours ago
#19430 new enhancement
BMimeType::GuessMimeType should check for existing file type attribute
Reported by: | grexe | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | Kits/Storage Kit | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
From looking at the source of MimeType.cpp
, there is room for optimization:
When I just want to get the MIME type of a file which *already has* a filetype attribute set, i.e. BEOS:TYPE
with a valid MIME type, it should *not* consult the MIME database again but just return the existing type from the attribute value.
Change History (3)
comment:1 by , 41 hours ago
comment:2 by , 18 hours ago
yes that's true, forgot about that. Curiously though, I get different results, e.g. for a Bookmark file:
BNodeInfo.GetType()
gives meapplication/x-vnd.Be-bookmark
,
but
BMimeType::GuessMimeType
gives meapplication/octet-stream
(using the same ref as source)
comment:3 by , 2 hours ago
Bookmarks have no contents (only attributes) so the MIME sniffer cannot guess their type based on the content.
The guessing here intentionally does not use the existing MIMe attribute, this allows for example "mimeset -f" to work.
But there could be a higher level API that calls BNodeInfo.GetType(), and only turns to GuessMimeType if the node has no usable attribute.
I would expect GuessMimeType to actually guess the type based on contents always. The file's already-set mimetype can be read separately already?