TMSU icon indicating copy to clipboard operation
TMSU copied to clipboard

Ignoring the file name extension on VFS access causes problems

Open dechamps opened this issue 2 years ago • 2 comments

Currently, the tmsu VFS does not check that the file extension matches when accessing a file. For example:

$ tmsu init
tmsu: /home/e-t172/tmp/tmsu: creating database
$ echo 'bar' > foo.txt
$ tmsu tag foo.txt foo
tmsu: new tag 'foo'
$ mkdir mnt
$ tmsu mount mnt
$ cat mnt/tags/foo/files/foo.1.txt
bar
$ cat mnt/tags/foo/files/foo.1.LITERALLY_ANYTHING
bar

This behaviour is problematic when using software that attempts to auto-detect the presence of axillary files with different extensions.

For example, my concrete use case is serving video files to a Windows machine (through Samba). The video player I use is MPC-HC, which, in its latest version, added a feature "loading chapter metadata from .xchp file". This means that, when I open, say a "foo.42.mp4" video file using MPC-HC, it will automatically try to load "foo.42.xchp". That file is not supposed to exist, but tmsu behaves as if it does. Next thing you know, MPC-HC is trying to parse a multi-GB file (since it's the same as the actual video file), and takes a long time to realize it's bogus (I suspect it's loading the entire file into memory), resulting in playback taking a very long time to start.

My suggestion would be to add an additional check to tmsu's code, around vfs.parseFileId(), to reject attempts to access files whose extensions don't match the actual file.

dechamps avatar Apr 02 '22 16:04 dechamps

For those hitting the exact same issue with MPC-HC, a workaround is to add this to your smb.conf:

veto files = *.xchp

Obviously that assumes you don't need access to any .xchp files anywhere in the share.

dechamps avatar Apr 02 '22 16:04 dechamps

Another example of client software getting confused by this behavior, this time the Heresphere VR video player: https://itch.io/t/3483439/crash-when-attempting-to-play-a-file-from-smb

dechamps avatar Feb 04 '24 10:02 dechamps