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

Address type-level crashes #1

Closed
tkellogg opened this issue Jan 2, 2022 · 2 comments · Fixed by #79
Closed

Address type-level crashes #1

tkellogg opened this issue Jan 2, 2022 · 2 comments · Fixed by #79
Labels
good first issue Good for newcomers stability Things that cause backups to not happen (crash, no start, no watch, etc.)

Comments

@tkellogg
Copy link
Owner

tkellogg commented Jan 2, 2022

This project is written in Rust so that the daemon can be very reliable. However, we have to actually take advantage of Rust's features to do that.

  1. Remove all .unwrap() calls
  2. Make cargo clippy pass
@tkellogg tkellogg added good first issue Good for newcomers stability Things that cause backups to not happen (crash, no start, no watch, etc.) labels Jan 2, 2022
@tkellogg
Copy link
Owner Author

tkellogg commented Jan 4, 2022

I made a little bit of progress in d32a7cf. The logging code in poller.rs now does a decent job of avoiding .unwrap().

@tkellogg
Copy link
Owner Author

tkellogg commented Jan 4, 2022

Current problems:

➜  dura git:(master) rg 'unwrap|expect'
src/main.rs
11:    let dir = std::env::current_dir().unwrap();
14:            if let Some(oid) = snapshots::capture(&dir).unwrap() {
38:    config.set_watch(path.to_str().unwrap().to_string(), WatchConfig::new());

src/log.rs
68:        let path = Config::default_path().parent().unwrap().join(file_name);
78:                eprintln!("Unable to write file {}", path.to_str().unwrap_or("n/a"));

src/snapshots.rs
41:        Some(&branch_commit.as_ref().unwrap_or(&head).tree()?),
58:        &[ branch_commit.as_ref().unwrap_or(&head) ],

src/poller.rs
23:    let repo = path.to_str().unwrap_or("<invalid path>").to_string();

src/config.rs
35:        .expect("Could not find your home directory!")
41:        Self::load_file(Self::default_path().as_path()).unwrap_or(Self::empty())
58:            .unwrap();
61:        serde_json::to_writer(writer, self).unwrap();
62:        println!("Wrote {}", path.to_str().unwrap());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers stability Things that cause backups to not happen (crash, no start, no watch, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant