mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
config: fix saving config file for hot/cold repo
This commit is contained in:
parent
96498846ec
commit
7e7104813a
@ -73,7 +73,9 @@ impl<BE: WriteBackend> WriteBackend for HotColdBackend<BE> {
|
||||
|
||||
async fn write_bytes(&self, tpe: FileType, id: &Id, buf: Vec<u8>) -> Result<()> {
|
||||
if let Some(be) = &self.hot_be {
|
||||
be.write_bytes(tpe, id, buf.clone()).await?;
|
||||
if tpe != FileType::Config {
|
||||
be.write_bytes(tpe, id, buf.clone()).await?;
|
||||
}
|
||||
}
|
||||
self.be.write_bytes(tpe, id, buf).await
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ use anyhow::{bail, Result};
|
||||
use bytesize::ByteSize;
|
||||
use clap::Parser;
|
||||
|
||||
use crate::backend::DecryptFullBackend;
|
||||
use crate::backend::{DecryptBackend, DecryptFullBackend, DecryptWriteBackend, WriteBackend};
|
||||
use crate::repo::ConfigFile;
|
||||
|
||||
#[derive(Parser)]
|
||||
@ -13,13 +13,24 @@ pub(super) struct Opts {
|
||||
|
||||
pub(super) async fn execute(
|
||||
be: &impl DecryptFullBackend,
|
||||
hot_be: &Option<impl WriteBackend>,
|
||||
opts: Opts,
|
||||
config: ConfigFile,
|
||||
) -> Result<()> {
|
||||
let mut new_config = config.clone();
|
||||
opts.config_opts.apply(&mut new_config)?;
|
||||
if new_config != config {
|
||||
new_config.is_hot = None;
|
||||
// for hot/cold backend, this only saves the config to the cold repo.
|
||||
be.save_file(&new_config).await?;
|
||||
|
||||
if let Some(hot_be) = hot_be {
|
||||
// save config to hot repo
|
||||
let dbe = DecryptBackend::new(hot_be, be.key().clone());
|
||||
new_config.is_hot = Some(true);
|
||||
dbe.save_file(&new_config).await?;
|
||||
}
|
||||
|
||||
println!("saved new config");
|
||||
} else {
|
||||
println!("config is unchanged");
|
||||
|
||||
@ -175,7 +175,7 @@ pub async fn execute() -> Result<()> {
|
||||
|
||||
match cmd {
|
||||
Command::Backup(opts) => backup::execute(&dbe, opts, config, command).await?,
|
||||
Command::Config(opts) => config::execute(&dbe, opts, config).await?,
|
||||
Command::Config(opts) => config::execute(&dbe, &be_hot, opts, config).await?,
|
||||
Command::Cat(opts) => cat::execute(&dbe, opts).await?,
|
||||
Command::Check(opts) => check::execute(&dbe, &cache, &be_hot, &be, opts).await?,
|
||||
Command::Diff(opts) => diff::execute(&dbe, opts).await?,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user