This ticket started from #6726 which has more background information and reasoning why this is a good idea. (Seafile does it like this as well.)
I looked into making the entire DocumentsProvider do its operations synchronously on the I/O thread that its methods are already called on. It actually already does this for most operations (move/rename/create/delete) and making the rest synchronous is quite straightforward and would improve the code as well. I'd be happy to provide a PR for that.
The only thing I am not sure about is the use of two SynchronizeFileOperations in DocumentsStorageProvider.
The first one happens when a file to be opened is available locally already. It is probably a good idea to sync this before, when the caller wants to read from the file. If you just want to write into the file, it might not be needed. However, syncing it can mean that async operations like uploads are triggered (and it can reveal conflicts we can't deal with here).
It would be easier if we can assume the local file to up-to-date, but I don't know if there's methods to check for that and how Nextcloud propagates server changes to its local cache.
The second use of SynchronizeFileOperation happens when a caller is done writing to a file and closed it. In this case, we probably don't need to do a sync, but can do a UploadFileRemoteOperation (like in createFile()) right away, right? Or maybe better use a UploadFileOperation so we get chunking for files that are two big.
@tobiasKaminsky do you want me to provide a PR for this and do you have thoughts about making the remaining operations synchronous, especially the two cases above?
@jmue since you contributed most of the to be modified code I would also be interested in your opinion.
This ticket started from #6726 which has more background information and reasoning why this is a good idea. (Seafile does it like this as well.)
I looked into making the entire
DocumentsProviderdo its operations synchronously on the I/O thread that its methods are already called on. It actually already does this for most operations (move/rename/create/delete) and making the rest synchronous is quite straightforward and would improve the code as well. I'd be happy to provide a PR for that.The only thing I am not sure about is the use of two
SynchronizeFileOperations inDocumentsStorageProvider.The first one happens when a file to be opened is available locally already. It is probably a good idea to sync this before, when the caller wants to read from the file. If you just want to write into the file, it might not be needed. However, syncing it can mean that async operations like uploads are triggered (and it can reveal conflicts we can't deal with here).
It would be easier if we can assume the local file to up-to-date, but I don't know if there's methods to check for that and how Nextcloud propagates server changes to its local cache.
The second use of
SynchronizeFileOperationhappens when a caller is done writing to a file and closed it. In this case, we probably don't need to do a sync, but can do aUploadFileRemoteOperation(like increateFile()) right away, right? Or maybe better use aUploadFileOperationso we get chunking for files that are two big.@tobiasKaminsky do you want me to provide a PR for this and do you have thoughts about making the remaining operations synchronous, especially the two cases above?
@jmue since you contributed most of the to be modified code I would also be interested in your opinion.