I want to copy a file ~5G to my Oneplus One(running cm-12.1-20151117-SNAPSHOT-YOG7DAO1K6) over MTP, but it fails at finishing copying. The copied file is 0KB so I delete it. Later I successfully copy the file over adb but I can't see the file over MTP when the phone is booted. I can only see the file over MTP when the phone is in twrp recovery.
There are some similar questions on this site but the answers don't work.
What I have tried:
Clear data on the Media Storage application and reboot. Doesn't help.
adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard. Doesn't help too. What's worse is that now I see even less files over MTP. I can only see all the files over MTP when the phone is in recovery.
Settings → Developer options → Development tools → Media Provider → Scan SD Card. Doesn't help.
 Deleting that large file and rescaning SD card makes all the files visible again over MTP. With that file on my phone, scanning SD card never finishes. For now I can only avoid saving large video files on the phone due to this glitch.