mirror of
https://github.com/PR0M3TH3AN/Marlin.git
synced 2025-09-09 07:38:50 +00:00
Merge pull request #48 from PR0M3TH3AN/codex/fix-failing-workflow-tests
Fix restore with backup ID
This commit is contained in:
@@ -9,9 +9,9 @@
|
|||||||
mod cli; // sub-command definitions and argument structs
|
mod cli; // sub-command definitions and argument structs
|
||||||
|
|
||||||
/* ── shared modules re-exported from libmarlin ─────────────────── */
|
/* ── shared modules re-exported from libmarlin ─────────────────── */
|
||||||
|
use libmarlin::backup::BackupManager;
|
||||||
use libmarlin::db::take_dirty;
|
use libmarlin::db::take_dirty;
|
||||||
use libmarlin::{config, db, logging, scan, utils::determine_scan_root};
|
use libmarlin::{config, db, logging, scan, utils::determine_scan_root};
|
||||||
use libmarlin::backup::BackupManager;
|
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use clap::{CommandFactory, Parser};
|
use clap::{CommandFactory, Parser};
|
||||||
@@ -107,9 +107,10 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
Commands::Restore { backup_path } => {
|
Commands::Restore { backup_path } => {
|
||||||
drop(conn);
|
drop(conn);
|
||||||
if backup_path.exists() {
|
if backup_path.exists() { db::restore(&backup_path, &cfg.db_path)
|
||||||
db::restore(&backup_path, &cfg.db_path)
|
.with_context(|| {
|
||||||
.with_context(|| format!("Failed to restore DB from {}", backup_path.display()))?;
|
format!("Failed to restore DB from {}", backup_path.display())
|
||||||
|
})?;
|
||||||
} else {
|
} else {
|
||||||
let backups_dir = cfg.db_path.parent().unwrap().join("backups");
|
let backups_dir = cfg.db_path.parent().unwrap().join("backups");
|
||||||
let manager = BackupManager::new(&cfg.db_path, &backups_dir)?;
|
let manager = BackupManager::new(&cfg.db_path, &backups_dir)?;
|
||||||
@@ -119,7 +120,10 @@ fn main() -> Result<()> {
|
|||||||
.context("invalid backup file name")?;
|
.context("invalid backup file name")?;
|
||||||
manager
|
manager
|
||||||
.restore_from_backup(name)
|
.restore_from_backup(name)
|
||||||
.with_context(|| format!("Failed to restore DB from {}", backup_path.display()))?;
|
.with_context(|| {
|
||||||
|
format!("Failed to restore DB from {}", backup_path.display())
|
||||||
|
})?;
|
||||||
|
|
||||||
}
|
}
|
||||||
println!("Restored DB from {}", backup_path.display());
|
println!("Restored DB from {}", backup_path.display());
|
||||||
db::open(&cfg.db_path).with_context(|| {
|
db::open(&cfg.db_path).with_context(|| {
|
||||||
|
Reference in New Issue
Block a user