Skip to content
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

feat(updater): use try_exists instead of exists #218

Merged
merged 2 commits into from
Apr 3, 2023

Conversation

felangel
Copy link
Contributor

@felangel felangel commented Apr 3, 2023

Description

As opposed to the exists() method, this one doesn't silently ignore errors unrelated to the path not existing. (E.g. it will return Err(_) in case of permission denied on some of the parent directories.)

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@felangel felangel requested review from eseidel and bryanoltman April 3, 2023 15:14
@felangel felangel self-assigned this Apr 3, 2023
@felangel felangel changed the title feat(updater): use try_exists instead of exists feat(updater): use try_exists instead of exists Apr 3, 2023
@@ -172,7 +172,7 @@ fn get_base_path(original_lib_app_paths: &Vec<String>) -> anyhow::Result<PathBuf
// Iterate through the paths and find the first one that exists.
for path in original_lib_app_paths {
let path = PathBuf::from(path);
if path.exists() {
if path.try_exists()? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the behavior of the method so that if there is an earlier path with permissions errors we will now error out of get_base_path, rather than previously we would have returned a valid later path.

Is that what you want?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good point I'll adjust the behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eseidel I adjusted the behavior lmk what you think, thanks!

Copy link
Contributor

@eseidel eseidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, feel free to land. You just might want to document the behavior change.

@felangel felangel requested a review from eseidel April 3, 2023 15:56
@felangel felangel merged commit b939ef0 into main Apr 3, 2023
@felangel felangel deleted the feat/updater-use-try-exists branch April 3, 2023 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants