Investigate the use of flock instead of lockf
Follow on from https://forum.mayan-edms.com/viewtopic.php?p=2895#p2895
A few users have had locking related errors either with NFS (generating static metadata) #551 #493 or with Samba where Mayan tries to process a file before it's scanned. Forum user Pleblancq currently patches the lockf to flock in watch_folder_sources.py to work around the issue. It's hard to say if this is caused by the scanner not using locks correctly or at the OS level the Mayan server is running on. I don't think is a bug per-se, more something to look into where switching to flock may resolve both sets of issues in one go or at the very least the watch folder related ones.
Django uses lockf due to cross-platform compatibility (https://code.djangoproject.com/ticket/9400) but devs there mention lockf does have some issues in some use cases. As we're not targeting Windows/MacOS support, switching to flock may provide the users with some benefit with no issue. In my own testing flock worked okay with my NFS and SMB backed shares (but I've been unable to re-create the initial watch folder processes unfinished file issue as my scanner handles locking correctly).
Ultimately these issues are often caused by either scanner firmware or configuration of the file server share (both server side and mounting side) and I do plan on adding some more documentation on known working setups for file shares soon but it may be worth thinking about what locking mechanism is best for watch folders and potentially use lockf for NFS and flock for samba or similar. Conversely; a "quiet period" to check if a file has updated proposed in #456 would make this redundant as well as provide additional benefits.