diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2024-02-15 00:37:53 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2024-02-15 00:38:03 +0100 |
commit | 2e43b759a84d9600e26557a7b02234d4429c2e4c (patch) | |
tree | 5a634312d410d95912c99378af6e5c49450e5a1a /hbak/src | |
parent | c3dc4f68afc63f7f3cf405cd6688139616a64afc (diff) |
hbak: introduce btrfs grace period for incremental snapshot restoration
Diffstat (limited to 'hbak/src')
-rw-r--r-- | hbak/src/main.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/hbak/src/main.rs b/hbak/src/main.rs index ce22b56..73c6b64 100644 --- a/hbak/src/main.rs +++ b/hbak/src/main.rs @@ -13,9 +13,15 @@ use std::fs::{self, File}; use std::io::{BufRead, BufReader, Empty}; use std::net::SocketAddr; use std::sync::Mutex; +use std::thread; +use std::time::Duration; use clap::{Parser, Subcommand}; +/// The grace period between btrfs invocations when restoring. +/// Ensures that incremental snapshots that depend on each other become accessible in time. +const BTRFS_GRACE_PERIOD: Duration = Duration::from_secs(2); + #[derive(Parser)] #[command(author, version, about, long_about = None)] struct Cli { @@ -508,6 +514,7 @@ fn restore( .ok_or(RemoteError::NotStreaming)?; if child.wait().map_err(|_| RemoteError::RxError)?.success() { + thread::sleep(BTRFS_GRACE_PERIOD); Ok(()) } else { Err(RemoteError::RxError) |