Here is the answer for the following questions, please feel to let me know if you still have the problem.
Questions 1:
I have implemented CF_CALLBACK_TYPE_FETCH_PLACEHOLDERS callback and CF_CALLBACK_TYPE_FETCH_DATA callback using Cloud Files Windows API and it is working well. Files sync from server to client properly.
Now at some point a file is modified on the server. How do I properly mark it as not in sync on the client?
Should I directly call the CfSetInSyncState() function?
Do I dehydrate the placeholder manually on the client using CfUpdatePlaceholder() or is it automatic?
What is the role of StorageProviderSyncRootInfo.InSyncPolicy in this process?
Answer 1:
Both CfSetInSyncState and CfUpdatePlaceholder can be used to mark something as insync or not insync.
However, usually a sync engine does not need to do so explicitly. The filter takes care of the insync state as a result of the local FS changes. For changes in the cloud, the sync engine usually just goes ahead and applies the changes without toggling the insync state. In fact, I would recommend sync engines never clearing insync. This can cause confusion after a crash because now the sync engine can’t easily tell why the file is not in-sync: was it because the user modified the file? Or was it because the sync engine cleared the in-sync bit itself before the crash? Different actions would be needed for either case. Conceptually, the in-sync state should be interpreted as “is there any data that hasn’t been uploaded to the cloud yet?”
Question 2:
How to update pinned file (cfapi)?
I am using the Cloud Files API. Here is my scenario:
- Files are synchronized from server to client.
- One file is pinned.
- The pinned file is changed on the server.
- The server notifies the client that the pinned file is modified.
Now how do I update the pinned file content? Do I dehydrate it or use any other API to update the content?
Answer 2:
There may be different ways of implementing this depending on what the provider wants to achieve. Provider may need to synchronize some aspects of the operation as well. Also, there is no Cf API available to merge contents.
An easy way would be to download the modified content locally into a temp file, rename the temp file onto the PINNED file (delete it first if needed), setting the pinned state and converting it back to a placeholder while marking it in-sync. Another way could be to overwrite the file with new content and then convert it back to placeholder and PINNED. The provider needs to figure what’s best and consider issues like what happens during a crash. There are also file system directory change notifications that could be used in various capacities.