Bug 358709

Summary: TS video files are recognized as text files on remote slaves
Product: [Frameworks and Libraries] frameworks-kio Reporter: cameronpoe
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: faure, kdelibs-bugs, sitter, steve
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=440631
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description cameronpoe 2016-01-28 21:56:28 UTC
nvd.trolltech.linguist mime type is blocking mp2t mime type for *.ts video files


Reproducible: Always

Steps to Reproduce:
1. Open catalog with TS video file.
2. Double click on that file.
3.

Actual Results:  
1. Doesn't show thumbnail for this video file, only txt icon.
2. Opens it with text editors.

Expected Results:  
1. Should show thumbnail for this video file.
2. Should open it with default video player.
Comment 1 Michael Pyne 2016-02-21 23:27:01 UTC
Adding dfaure since he has more experience here.

But I've dug into it and I've confirmed that there are mimetypes for both linguist .ts and mp2t .ts files in shared-mime-info (1.4), and that both types also have proper 'magic' in /usr/share/mime/magic.

I'm not sure how ties are broken in the event two possible mimetypes match a filename pattern, but at least on my system Dolphin properly treats a sample .ts file I downloaded as a movie, not as a Linguist XML file.

If you have updated shared-mime-info packages then the only way I can see a KDE bug here is if we're calculating the 'tiebreaker' wrong (whether that's by using file magic or something else).
Comment 2 cameronpoe 2016-02-22 16:39:49 UTC
My shared-mime-info is 1.2-3.3 and that is highest official version in newest openSUSE 42.1 Leap :(
Comment 3 cameronpoe 2016-02-24 12:47:14 UTC
I updated shared-mime-info to version 1.5 but unfortunately this problem STILL EXISTS !!!
Comment 4 S. Bryant 2017-01-22 16:52:47 UTC
It's still a problem with shared-mime-info 1.6 too (Leap 42.2).  I suspect very strongly that the shared MIME info is not the problem, but - assuming the magic numbers are correct - the problem is that the checking fails.

What is worse: there is no way to change the default (Plasma5 5.8).  If I remove "*.ts" from the linguist definition using System Settings, it is still there the next time I go in.  The method used to override system MIME settings is not working.

The default itself is also unreasonable: the number of users who want to watch videos/TV they've recorded will far outweigh the number who use Qt Linguist.  That said, this point is irrelevant if magic number checking is working.
Comment 5 Harald Sitter 2020-09-06 21:07:23 UTC
Is this still a problem?
Comment 6 S. Bryant 2020-09-10 09:39:52 UTC
This is not quite fixed properly (Plasma 5.19.5 on openSUSE 15.2).

Dolphin will now correctly differentiate for local files, but _not_ for 'sftp://' - it wants to open MPEG files with Linguist.  The same is true for 'webdavs://'.  I haven't tested other IO slaves.

For 'file://', I notice that Typescript files are also correctly identified as plain text, despite sharing the same '*.ts' naming.
Comment 7 Harald Sitter 2020-09-10 10:36:43 UTC
I can reproduce by simply navigating to a dir with typescript files, they all are message catalogs and open with linguist.
Moving the bug to KIO.

I am not quite sure what can be done about this though. Determining the mimetype when multiple types have the same file suffix involves downloading a portion of the file and looking for a magic sequence of bytes. For obvious reasons we do not do that on non-local slave types as we'd flood the network and server with a gazillion requests when entering a directory with a gazillion files. Because of that the only information we have to go on is the suffix, meaning only one type can win even when there would be multiple candidates.
Comment 8 Christoph Feck 2020-09-10 10:39:57 UTC
Would it be possible to respect the user preference for application order?
Comment 9 Harald Sitter 2020-09-10 11:29:59 UTC
Do you mean application order associated with a mimetype? That is already honored, the trouble is we get the wrong mimetype.
That being said as a workaround a user could mangle that mimetype by either unassigning the suffixes or simply adding the desired applications.
Comment 10 S. Bryant 2020-09-10 11:36:19 UTC
> Determining the mimetype when multiple types have the same file suffix involves downloading a portion of the file and looking for a magic sequence of bytes. For obvious reasons we do not do that on non-local slave types as we'd flood the network and server with a gazillion requests when entering a directory with a gazillion files.

While this is true, it may or may not be a problem, and may even be preferred behaviour.  If I'm going across the Internet, it causes problems.  However, when I access files on a local server across a gigabit LAN, I'd like the option to have the gazillion requests made.

Dolphin already does this, based on file size. Preferences->General->Previews: "Skip previews for remote files above" (size).

Would it not be possible to use the same setting to determine whether to perform magic number checking?  At least, can data obtained for previews not also be used for magic numbers?
Comment 11 Harald Sitter 2020-09-10 12:25:23 UTC
Perhaps, in lieu of a better solution.