diff --git a/src/index/mimetype.cpp b/src/index/mimetype.cpp index b37f6249..d6735011 100644 --- a/src/index/mimetype.cpp +++ b/src/index/mimetype.cpp @@ -46,15 +46,21 @@ using namespace std; /// current/interesting file types. /// As a last resort we execute 'file' (except if forbidden by config) -static string mimetypefromdata(const string &fn, bool usfc) +static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc) { // First try the internal identifying routine string mime = idFile(fn.c_str()); #ifdef USE_SYSTEM_FILE_COMMAND if (usfc && mime.empty()) { - // Last resort: use "file -i" + // Last resort: use "file -i", or its configured replacement. vector cmd = create_vector(FILE_PROG) ("-i") (fn); + string scommand; + if (cfg->getConfParam("systemfilecommand", scommand)) { + stringToStrings(scommand, cmd); + cmd.push_back(fn); + } + string result; if (!ExecCmd::backtick(cmd, result)) { LOGERR(("mimetypefromdata: exec %s failed\n", FILE_PROG)); @@ -164,7 +170,7 @@ string mimetype(const string &fn, const struct stat *stp, // only do this if we have an actual file (as opposed to a pure // name). if (mtype.empty() && stp) - mtype = mimetypefromdata(fn, usfc); + mtype = mimetypefromdata(cfg, fn, usfc); out: return mtype; diff --git a/src/sampleconf/recoll.conf.in b/src/sampleconf/recoll.conf.in index 447100ec..72e38b81 100644 --- a/src/sampleconf/recoll.conf.in +++ b/src/sampleconf/recoll.conf.in @@ -189,6 +189,10 @@ iconsdir = @prefix@/share/recoll/images # identification ? This may be useful, but will usually cause the # indexation of many bogus 'text' files usesystemfilecommand = 1 +# Actual command to use as "file -i" workalike. xdg-mime works fine here. +# The file path will be added as a last parameter to the command line. If +# that's not what your preferred command would like, use an intermediary script +# systemfilecommand = xdg-mime query filetype # Should we index the file names of files with mime types we don't # know? (we can otherwise just ignore them)