diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-22 14:17:38 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-22 14:17:38 +0200 |
commit | d23fa7990ddd2bd7388917d0bb693caaa2defd3f (patch) | |
tree | 3acc218d80c6facd5dabce940d4cd540ea7b467f /src | |
parent | 17da04d6114915bf132d9e2ccb5ed2df44988db1 (diff) | |
download | obnam2-d23fa7990ddd2bd7388917d0bb693caaa2defd3f.tar.gz |
refactor: use the same ClientConfig for both backups and restores
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/restore.rs | 18 |
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, |