-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
prevent file data loss due to replacing an open file handle (partial fix for #5275) #5276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughCalls to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
prevent file data loss due to replacing an open file handle (partial fix for #5275) - provides better protection again presets.json corruption.
The function
writeObjectToFile()was re-assigningf(global file handle, file.cpp) without first completing any pending write operations on f.Reassigning a file pointer thats still in use can lead to loss of data and file corruption.
This PR provides a fix by first checking for pending writes (doCloseFile == true) and calling f.close() when needed.
The same protection code is already preset in
readObjectFromFile(), it looks like protectingwriteObjectToFile()was forgotten.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.