File updating algorithm

Hi everyone!!

I have been trying to understand how the updating of a file occurs in the Nextcloud desktop app. I know there are constant checks of modification time and Etag number of local and remote files, but what exactly happens when a change is detected?

This has been bugging me and I cannot find a definitive answer. Any information is much appreciated.