test "mime_type" extended attribute before trying other type recognition methods
This commit is contained in:
parent
2f32856f55
commit
17ecc9d7bb
1 changed files with 12 additions and 0 deletions
|
@ -31,6 +31,7 @@ using namespace std;
|
||||||
#include "rclconfig.h"
|
#include "rclconfig.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
#include "idfile.h"
|
#include "idfile.h"
|
||||||
|
#include "pxattr.h"
|
||||||
|
|
||||||
/// Identification of file from contents. This is called for files with
|
/// Identification of file from contents. This is called for files with
|
||||||
/// unrecognized extensions.
|
/// unrecognized extensions.
|
||||||
|
@ -115,6 +116,11 @@ string mimetype(const string &fn, const struct stat *stp,
|
||||||
{
|
{
|
||||||
// Use stat data if available to check for non regular files
|
// Use stat data if available to check for non regular files
|
||||||
if (stp) {
|
if (stp) {
|
||||||
|
// Note: the value used for directories is different from what
|
||||||
|
// file -i would print on Linux (inode/directory). Probably
|
||||||
|
// comes from bsd. Thos may surprise a user trying to use a
|
||||||
|
// 'mime:' filter with the query language, but it's not work
|
||||||
|
// changing (would force a reindex).
|
||||||
if (S_ISDIR(stp->st_mode))
|
if (S_ISDIR(stp->st_mode))
|
||||||
return "application/x-fsdirectory";
|
return "application/x-fsdirectory";
|
||||||
if (!S_ISREG(stp->st_mode))
|
if (!S_ISREG(stp->st_mode))
|
||||||
|
@ -123,6 +129,12 @@ string mimetype(const string &fn, const struct stat *stp,
|
||||||
|
|
||||||
string mtype;
|
string mtype;
|
||||||
|
|
||||||
|
// Extended attribute has priority on everything, as per:
|
||||||
|
// http://freedesktop.org/wiki/CommonExtendedAttributes
|
||||||
|
if (pxattr::get(fn, "mime_type", &mtype)) {
|
||||||
|
return mtype;
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg == 0) // ?!?
|
if (cfg == 0) // ?!?
|
||||||
return mtype;
|
return mtype;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue