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:
parent
b7decc0848
commit
4447b6f147
1 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue