-
Notifications
You must be signed in to change notification settings - Fork 386
fix: object_store: stop throwing errors when checking generation file #832
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdded a public static File::exists(path) that checks file existence using platform-specific calls (non-Windows: stat; Windows: _access). Generation::wasUpdated() now short-circuits by returning true when the generation file is missing, avoiding attempts to open it. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings🧬 Code graph analysis (2)src/lib/object_store/File.h (2)
src/lib/object_store/Generation.cpp (2)
🔇 Additional comments (2)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/lib/object_store/File.h (1)
50-54: Consider passing path by const reference for efficiency.The
pathparameter is passed by value, creating an unnecessary string copy.Apply this diff to pass by const reference:
- static bool exists(std::string path); + static bool exists(const std::string& path);src/lib/object_store/File.cpp (1)
149-149: Parameter should be passed by const reference.As noted in the File.h review, the
pathparameter creates an unnecessary copy. Apply the same change here to match the header declaration once updated.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/lib/object_store/File.cpp(1 hunks)src/lib/object_store/File.h(1 hunks)src/lib/object_store/Generation.cpp(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: bukka
Repo: softhsm/SoftHSMv2 PR: 815
File: src/lib/SoftHSM.cpp:6543-6546
Timestamp: 2025-09-11T16:54:00.370Z
Learning: SoftHSM PR #815 (pkcs11.h 3.1.0 update, CK_RSA_AES_KEY_WRAP_PARAMS fix): Maintainer bukka prefers to keep scope minimal (header sync and param rename only); broader OAEP parameter enforcement or backend plumbing is out of scope for this PR and should be handled in a follow-up issue.
🧬 Code graph analysis (3)
src/lib/object_store/File.cpp (1)
src/lib/object_store/test/FileTests.cpp (2)
exists(355-377)exists(355-355)
src/lib/object_store/File.h (2)
src/lib/object_store/File.cpp (2)
exists(149-165)exists(149-149)src/lib/object_store/test/FileTests.cpp (2)
exists(355-377)exists(355-355)
src/lib/object_store/Generation.cpp (2)
src/lib/object_store/File.cpp (2)
exists(149-165)exists(149-149)src/lib/object_store/test/FileTests.cpp (2)
exists(355-377)exists(355-355)
🔇 Additional comments (1)
src/lib/object_store/Generation.cpp (1)
91-96: LGTM - Effectively prevents spurious error logs.The early existence check successfully avoids attempting to open non-existent generation files, directly addressing issue #753. Returning
truewhen the file doesn't exist is consistent with the existing behavior at lines 104-107 and 130-133, where invalid files also returntrue.
A new routine is added to File class, to check whether a file exists or not. It will allow file existence check, without trying to open the file and thus throw an error when the use case is valid. This new routine is added to Generation wasUpdated routine: if the generation file does not exist, the routine will exit without error, instead of trying to open the file and report an error. Fixes softhsm#753 Signed-off-by: Alexandre Besnard <alexandre.besnard@softathome.com>
dda968a to
8f49d40
Compare
A new routine is added to File class, to check whether a file exists or not. It will allow file existence check, without trying to open the file and thus throw an error when the use case is valid.
This new routine is added to Generation wasUpdated routine: if the generation file does not exist, the routine will exit without error, instead of trying to open the file and report an error.
Fixes #753
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.