Ugly indeed.
Obviously, the Linux file system is massively cached but thats really not the user's business except during a power down event. And there we have the sync command.
That write up does not mention a standalone command/api call, just parameters to CreateFile. So, difficult to use with copyfile() or deletefile().
StackOverflow has quite a lot of (negative) discussion.
I suspect what we are seeing is a conflict between Windows read-cache and write-caches. One file has been read, is therefore in the read cache, its then either deleted or overwritten via the write-cache and suddenly, the write-cache does not agree with the read-cache.
A possible solution is to abandon the (very useful) process of writing the file out as a tmp file and then moving it onto the real file. While very good practice from a data safety principle, it confuses Window's cache. Yet, its on NTFS that the process is particularly valuable. ext3 and ext4 are well journaled.
Sigh ....