paperless icon indicating copy to clipboard operation
paperless copied to clipboard

inotify not being triggered on SFTP file transfer

Open jat255 opened this issue 5 years ago • 1 comments

I have paperless setup in an lxc unprivileged container, which works mostly okay, but I've noticed that if I use my laptop's file browser (KDE Dolphin) to upload a file to my paperless consumption directory via SFTP, the consumer does not see the event and trigger consumption.

I can confirm that it triggers an inotify event when uploading the file, as I see the following output on my paperless host when watching the directory and uploading a file via SFTP:

$  inotifywatch -v -e moved_to -e close_write -r /data/consumption
Establishing watches...
Setting up watch(es) on /data/consumption
OK, /data/consumption is now being watched.
Total of 1 watches.

[Upload file via SFTP then press Ctrl-C...]

Finished establishing watches, now collecting statistics.
total  close_write  filename
1      1            /data/consumption/

I monitored those two inotify events because those are the ones monitored on this line of the consumer. I cannot see why this wouldn't work.

My paperless user has full rights to the file:

-rw-r--r--+ 1 paperless paperless 778K May 21 11:09  file_to_consume.pdf

Some more debugging shows that this in the log:

May 21 11:52:10 paperless python3[19865]: Skipping /data/consumption/file_to_consume.pdf.part as it is not a file

So it looks like because Dolphin uploads a .part file and then renames it, the original file gets ignored, and the rename is not detected via inotify

jat255 avatar May 21 '20 17:05 jat255

Copying via scp works as expected

jat255 avatar May 21 '20 18:05 jat255