Hi,
Although I do not have a real solution I have experienced a lot of issues with this myself and have come up with semi-explanation and a workaround .
What I think is going on: (not a very technical explanation
)
OneDrive tries to sync files as soon as they change on disk. This is to ensure that various syncing folders stay up to date. That's all very well when we're talking about regular files like a word document or an image, but RStudio both generates a lot temporary files (e.g. in hidden folders) and sometimes seems to lock several of the files depending on the situation. Locked files can't be synced, and sometimes the fast pace at which temp files are changed break the sync too. If you use git, even more hidden files are generated.
The reason I got a lot of trouble with it is that during developing and running shiny apps, OneDrive was going crazy trying to sync a lot of files and eating away CPU and breaking stuff. Again, since Shiny runs in the folder you're working on, it creates files on the fly.
Finally, the reason OneDrive complains you're deleting a lot of files is because this is a safety measure they use to help people prevent deleting folders with a lot of files by accident. Again, the files that are deleted in this case are all the temp files in the hidden folders that we don't care about, so the warning is useless and annoying.
How I avoid the issues: (not a solution)
I've written a little (batch )script in Windows that I call when I click a fake RStudio icon. It will automatically shut down OneDrive before starting RStudio. This way there is no syncing when I'm working in R. I haven't found an easy way for the same script to detect when I close RStudio, so for now I manually start OneDrive again when I close R.
This approach is not perfect, but I no longer have syncing issues and do not get the warnings for deleting too many files.
Hope this helps,
PJ