-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
fix(unpack): set environment variable if already unpacked #1409
Conversation
Ensure the environment variable is set when the file exists to prevent possible issues with subsequent operations.
WalkthroughThe Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 0
🧹 Outside diff range and nitpick comments (2)
binaries/unpack/unpack.go (2)
39-41
: LGTM! Consider improving the error message.The environment variable setting is now consistent between existing and newly unpacked files. However, the panic error message could be more descriptive.
- panic(err) + panic(fmt.Errorf("failed to set environment variable %s: %w", FileEnv, err))
39-41
: Consider refactoring to reduce duplication and improve error handling.The environment variable setting logic is duplicated and the extensive use of panic could be improved. Consider extracting the common functionality and implementing proper error handling.
func Unpack(data []byte, name string, version string) { + if err := doUnpack(data, name, version); err != nil { + panic(err) + } +} + +func setQueryEnginePath(file string) error { + if err := os.Setenv(FileEnv, file); err != nil { + return fmt.Errorf("failed to set environment variable %s: %w", FileEnv, err) + } + return nil +} + +func doUnpack(data []byte, name string, version string) error { start := time.Now() // ... existing setup code ... if _, err := os.Stat(file); err == nil { - if err := os.Setenv(FileEnv, file); err != nil { - panic(err) + if err := setQueryEnginePath(file); err != nil { + return err } logger.Debug.Printf("query engine exists, not unpacking. %s. at %s", time.Since(start), file) - return + return nil } // ... existing unpacking code ... - if err := os.Setenv(FileEnv, file); err != nil { - panic(err) - } + return setQueryEnginePath(file) }
Ensure the environment variable is set when the file exists to prevent possible issues with subsequent operations.
Summary by CodeRabbit
New Features
PRISMA_INTERNAL_QUERY_ENGINE_PATH
environment variable when a file exists.Bug Fixes