z411 / trackma

Open multi-site list manager for Unix-like systems. (ex-wMAL)
https://z411.github.io/trackma
GNU General Public License v3.0
779 stars 81 forks source link

inotify tracking does not work through SSHFS #374

Open FichteFoll opened 6 years ago

FichteFoll commented 6 years ago

The tracker used to work, but it doesn't anymore. I think since the last update, which was on 2018-09-26, where I updated 0.7.6.r3.g7954a73-1 -> 0.7.6.r8.gb9e26e1-1 (so after 7954a73, probably), and it also doesn't work with current master.

I don't receive any mentions of the tracker finding something, despite even using trackma to play the next episode. My player is mpv and my config is as follows:

{
    "auto_date_change": true,
    "auto_status_change": true,
    "auto_status_change_if_scored": true,
    "autoretrieve": "days",
    "autoretrieve_days": 3,
    "autosend": "minutes",
    "autosend_at_exit": true,
    "autosend_minutes": 5,
    "autosend_size": 5,
    "debug_disable_lock": true,
    "library_autoscan": true,
    "player": "mpv",
    "plex_host": "localhost",
    "plex_obey_update_wait_s": false,
    "plex_passwd": "",
    "plex_port": "32400",
    "plex_user": "",
    "plex_uuid": "e3c03de6-f418-11e7-810e-00133b0f1f1e",
    "scan_whole_list": false,
    "searchdir": "/data/Video/Anime",
    "tracker_enabled": true,
    "tracker_interval": 10,
    "tracker_not_found_prompt": false,
    "tracker_process": "mpv",
    "tracker_type": "local",
    "tracker_update_close": false,
    "tracker_update_prompt": false,
    "tracker_update_wait_s": 540.0
}
FichteFoll commented 6 years ago

Coincidentally I discovered that the tracker does work when I play episodes from a different location, i.e. my local hard drive. When I play them from a symlinked folder that is an sshfs mount (symlink because you can only set one media folder), it doesn't work.

Not sure if the symlink is really the problem here, but at least the library scanner works with them, which would be the first thing I expect to break.

z411 commented 5 years ago

Thanks for the report. Are you using the inotify or polling tracker? (This should appear in the log/status bar) From what I remember, symlinks don't seem to be working with inotify. The library scanner uses a different method to traverse the directories, which would explain why it works.

FichteFoll commented 5 years ago

I'm quite confident I'm using inotify. I also seem to remember that notifications don't work with symlinks, but maybe you could add listens for each symlink discovered while crawling through the library? Or do this kind of crawl manually on start because people might have media scanning disabled. Or maybe it works with polling as well. I should try that.

Either way, this would also be solved by #179 as currently I have to edit the config to cycle between three different directories depending on where I stored my media (yes, I have multiple locations).

z411 commented 5 years ago

@FichteFoll I've implemented multiple directories in the develop branch, please check if it works for you.

That said, I'll still debug symlinks. I haven't done any conscious change that would stop the library from traversing symlinks (pyinotify).

z411 commented 5 years ago

I just now looked into this, my bad. Effectively FUSE filesystems like SSHFS don't support inotify so it's expected that the inotify tracker wouldn't work. The library scanner uses regular directory scanning so it works. I'm afraid the inotify tracker wouldn't work even if you used the new multiple directories feature over your SFTP connection.

You could try to force the use of the polling tracker by specifying polling as the tracker_type in your config.json.

FichteFoll commented 5 years ago

Thanks for investigating. I'll make a menta note to confirm this as soon as get to it.

Birdulon commented 5 years ago

FWIW my library has always been on a sshfs mount and inotify has worked on it. It definitely uses inotify as I had to increase the maximum number of watches to use certain other programs with trackma running. I was not using symlinks though!

z411 commented 5 years ago

Oh really, I should recheck it then. inotify will definitely not work remotely but if it works for you then it is generating inotify events if it occurs locally. I'll try with an SSH mount myself.

Birdulon commented 5 years ago

Yeah, it receives local events (e.g. me watching episodes or creating/copying/moving folders around on the mount) but not remote ones (moving folders around via the remote torrent client, new series folders being created by flexget etc.).

FichteFoll commented 5 years ago

I also believe that this did work fine for me before as I was always using inotify and manually edited my media directory setting before launching trackma due to #179. (Still wasn't able to actually confirm this.)

z411 commented 5 years ago

@FichteFoll Last question, does the issue occur with pyinotify or inotify? (They're different trackers actually, it should say which one it's using in the terminal when it starts)

FichteFoll commented 5 years ago

I am indeed using pyinotify. I can try to experiment a bit, but I'll be out of town for a while and won't have time for this for a few weeks.

amhndu commented 5 years ago

pyinotify doesn't work through symlinks, it took me until reading the source for trackma and pyinotify to figure out why trackma wouldn't work for me. I think this, along with how the different trackers work (ie. the inotify trackers only work for files played under the selected media directory) should be documented somewhere. I'm not sure if this remote issue is related to pyinotify's limitations on symlinks, but I thought I should mention this here.