Best way to implement continuos file locking

In my nextcloud app i need to lock files for long time period, lest say about 10-60 minutes, while they are being edited in an external application.
I found, that because of that call
register_shutdown_function(array($lockProvider, ‘releaseAll’));
all locks automatically released in the end of request.
I implemented my own table to store locks with additional information, so whats best way to keep files locked?
May be i can discard autounlock in some way and remove locks that out of ttl by background job?
I found this event
$dispatcher->dispatch(‘OCA\DAV\Connector\Sabre::addPlugin’, $event);
where i can register my own plugin to lock files before LockPlugin that gets lock when file uploding through dav, but may be there is more reliable (global) way.

Looks like temporarely locking files in preWrite is the best choice :slightly_smiling_face: