summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-11-22 12:18:54 +0000
committerLars Wirzenius <liw@liw.fi>2020-11-22 12:18:54 +0000
commit0158bd9c06acae4245897e5e04681b4a1637bee9 (patch)
tree3acc218d80c6facd5dabce940d4cd540ea7b467f
parent17da04d6114915bf132d9e2ccb5ed2df44988db1 (diff)
parentd23fa7990ddd2bd7388917d0bb693caaa2defd3f (diff)
downloadobnam2-0158bd9c06acae4245897e5e04681b4a1637bee9.tar.gz
Merge branch 'config' into 'main'
refactor: use the same ClientConfig for both backups and restores See merge request larswirzenius/obnam!19
-rw-r--r--src/cmd/restore.rs18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/cmd/restore.rs b/src/cmd/restore.rs
index 8aa0345..7956b5f 100644
--- a/src/cmd/restore.rs
+++ b/src/cmd/restore.rs
@@ -1,16 +1,15 @@
use crate::client::BackupClient;
+use crate::client::ClientConfig;
use crate::fsentry::{FilesystemEntry, FilesystemKind};
use crate::generation::Generation;
use log::{debug, info};
-//use obnam::chunkmeta::ChunkMeta;
-use serde::Deserialize;
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use structopt::StructOpt;
pub fn restore(config: &Path, gen_id: &str, dbname: &Path, to: &Path) -> anyhow::Result<()> {
- let config = Config::read_config(&config).unwrap();
+ let config = ClientConfig::read_config(&config).unwrap();
let client = BackupClient::new(&config.server_url)?;
let gen_chunk = client.fetch_generation(&gen_id)?;
@@ -48,19 +47,6 @@ struct Opt {
to: PathBuf,
}
-#[derive(Debug, Deserialize, Clone)]
-pub struct Config {
- pub server_url: String,
-}
-
-impl Config {
- pub fn read_config(filename: &Path) -> anyhow::Result<Config> {
- let config = std::fs::read_to_string(filename)?;
- let config: Config = serde_yaml::from_str(&config)?;
- Ok(config)
- }
-}
-
fn restore_generation(
client: &BackupClient,
gen: &Generation,