Skip to content

Commit

Permalink
feat(snapshot): Only take snapshot for database, do not affect worksp…
Browse files Browse the repository at this point in the history
…ace (#74)
  • Loading branch information
fioncat authored Dec 29, 2023
1 parent 52602b7 commit d45f7ee
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 385 deletions.
17 changes: 2 additions & 15 deletions src/cmd/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ impl Run for RecoverArgs {
match Database::load(cfg) {
Ok(_) => {}
Err(err) => {
info!("Database has problem: '{}', replace it with a new one. The old one will be saved to '{}/database.back'", err, cfg.get_meta_dir().display());
info!("Database has problem: '{}', replace it with a new one", err);
confirm!("Continue");
Self::replace_database(cfg)?;
database::backup_replace(cfg, "recover")?;
}
};

Expand Down Expand Up @@ -59,19 +59,6 @@ impl Run for RecoverArgs {
}

impl RecoverArgs {
fn replace_database(cfg: &Config) -> Result<()> {
let old_path = cfg.get_meta_dir().join("database");
let new_path = cfg.get_meta_dir().join("database.back");
fs::rename(&old_path, &new_path).with_context(|| {
format!(
"rename '{}' to '{}'",
old_path.display(),
new_path.display()
)
})?;
Ok(())
}

fn scan_workspace(cfg: &Config) -> Result<Vec<Repo>> {
info!("Scanning workspace");
let mut repos = Vec::new();
Expand Down
Loading

0 comments on commit d45f7ee

Please sign in to comment.