// We use temporary directories for everything, so in the case of failure save the directories
// for inspection, and then panic with the error message.
We use temporary directories for everything, so in the case of failure save the directories
for inspection, and then panic with the error message.
We use temporary directories for everything so in the case of failure save the directories for inspection and then panic with the error message .
fn handle_failed_restore<P: AsRef<Path>, Q: AsRef<Path>>(original_dir: P, restore_dir: Q, reason: &str, err: &str) {
	let random_str: String = rand::thread_rng().sample_iter(&rand::distributions::Alphanumeric).take(10).collect();
	fs::rename(original_dir, "/tmp/preserve-test-failed-original-".to_string() + &random_str).unwrap();
	fs::rename(restore_dir, "/tmp/preserve-test-failed-restore-".to_string() + &random_str).unwrap();
	panic!("{}\nOriginal and Restore directories have been saved for inspection: /tmp/preserve-test-failed-*-{}\nrsync output:\n{}", reason, random_str, err)
}
fn handle_failed_restore < P : AsRef < Path > , Q : AsRef < Path > > ( original_dir : P , restore_dir : Q , reason : & str , err : & str ) { let random_str : String = rand :: thread_rng ( ) . sample_iter ( & rand :: distributions :: Alphanumeric ) . take ( 10 ) . collect ( ) ; fs :: rename ( original_dir , " " . to_string ( ) + & random_str ) . unwrap ( ) ; fs :: rename ( restore_dir , " " . to_string ( ) + & random_str ) . unwrap ( ) ; panic ! ( " \n \n \n " reason random_str err ) }
We use temporary directories for everything, so in the case of failure save the directories
for inspection, and then panic with the error message.
We use temporary directories for everything so in the case of failure save the directories for inspection and then panic with the error message .
original_dir
P
restore_dir
Q
reason
&str
err
&str