Try to match as long a suffix as possible when determining MIME type. This will allow .tar.gz files to be indexed directly instead of being decompressed to a temp file first.

This commit is contained in:
Jean-Francois Dockes 2015-04-16 19:52:04 +02:00
parent b7decc0848
commit 4447b6f147

View file

@ -159,11 +159,13 @@ string mimetype(const string &fn, const struct stat *stp,
}
// Compute file name suffix and search the mimetype map
string::size_type dot = fn.find_last_of(".");
string suff;
if (dot != string::npos) {
suff = stringtolower(fn.substr(dot));
string::size_type dot = fn.find_first_of(".");
while (dot != string::npos) {
string suff = stringtolower(fn.substr(dot));
mtype = cfg->getMimeTypeFromSuffix(suff);
if (!mtype.empty() || dot >= fn.size() - 1)
break;
dot = fn.find_first_of(".", dot + 1);
}
// If type was not determined from suffix, examine file data. Can