Is it possible for an app to block a particular file operation via a Filesystem hook?
E.g. if the app were to register listening for a preWrite or preDelete hook, perform some test, and determine that the user should not be allowed to proceed with the operation, can the app terminate/block that operation?
Or is it only possible to perform some app specific action prior to Nextcloud proceeding with whatever operation the hook relates to, with no way to prevent the operation from being performed?
If I were you, I would try throwing an Exception and see if it fits your needs.
That approach came to mind, but I’m thinking more along the lines of offering the user a dialog with a “Cancel” option, which terminates the operation without any fuss, and presumably an exception would result in a less gracious response from Nextcloud. Granted, there’s nothing like just writing code to play around, but I thought it might be useful to ask first, if anyone had done anything similar…
Well you can set the filesystem hook parameter
$run to false. That should stop the execution. However as per above, I think JS is more what you are looking for.
The JS approach will be fine for browser users, but I’m needing consistent behavior regardless of the method of interaction (browser, webdav, client, etc.) so it would need to be managed on the server side, as part of the core functionality utilized by all methods of filesystem interaction.
The Files app is more oriented ‘cancel after action’. So providing a confirmation box in all clients/frontend will require a lot of work.
Do access mechanisms such as webdav work in conjunction with the Files app, or do they work independently from the Files app? I.e. is there a core component / app that manages file operations irregardless of whether one uses the web UI, webdav mounted directory, desktop client, etc. and is that the Files app?
I’m wondering if it may be necessary to actually tweak the core in some manner to achieve the needed behavior, though ideally, I’d prefer to limit things to an app and not have to touch the core.
How I get $run parameter? In documentation there is only one parameter $node.