summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backup_progress.rs36
-rw-r--r--src/cipher.rs2
-rw-r--r--src/cmd/init.rs2
-rw-r--r--src/cmd/restore.rs6
-rw-r--r--src/passwords.rs2
5 files changed, 34 insertions, 14 deletions
diff --git a/src/backup_progress.rs b/src/backup_progress.rs
index 1e6805c..e3995f0 100644
--- a/src/backup_progress.rs
+++ b/src/backup_progress.rs
@@ -2,7 +2,7 @@
use crate::generation::GenId;
use indicatif::{ProgressBar, ProgressStyle};
-use std::path::Path;
+use std::{path::Path, time::Duration};
const SHOW_PROGRESS: bool = true;
@@ -29,8 +29,12 @@ impl BackupProgress {
"current: {wide_msg}",
"{spinner}",
];
- progress.set_style(ProgressStyle::default_bar().template(&parts.join("\n")));
- progress.enable_steady_tick(100);
+ progress.set_style(
+ ProgressStyle::default_bar()
+ .template(&parts.join("\n"))
+ .expect("create indicatif ProgressStyle value"),
+ );
+ progress.enable_steady_tick(Duration::from_millis(100));
Self { progress }
}
@@ -50,8 +54,12 @@ impl BackupProgress {
"current: {wide_msg}",
"{spinner}",
];
- progress.set_style(ProgressStyle::default_bar().template(&parts.join("\n")));
- progress.enable_steady_tick(100);
+ progress.set_style(
+ ProgressStyle::default_bar()
+ .template(&parts.join("\n"))
+ .expect("create indicatif ProgressStyle value"),
+ );
+ progress.enable_steady_tick(Duration::from_millis(100));
Self { progress }
}
@@ -64,8 +72,12 @@ impl BackupProgress {
"elapsed: {elapsed}",
"{spinner}",
];
- progress.set_style(ProgressStyle::default_bar().template(&parts.join("\n")));
- progress.enable_steady_tick(100);
+ progress.set_style(
+ ProgressStyle::default_bar()
+ .template(&parts.join("\n"))
+ .expect("create indicatif ProgressStyle value"),
+ );
+ progress.enable_steady_tick(Duration::from_millis(100));
Self { progress }
}
@@ -75,8 +87,12 @@ impl BackupProgress {
pub fn download_generation(gen_id: &GenId) -> Self {
let progress = ProgressBar::new(0);
let parts = ["{msg}", "elapsed: {elapsed}", "{spinner}"];
- progress.set_style(ProgressStyle::default_bar().template(&parts.join("\n")));
- progress.enable_steady_tick(100);
+ progress.set_style(
+ ProgressStyle::default_bar()
+ .template(&parts.join("\n"))
+ .expect("create indicatif ProgressStyle value"),
+ );
+ progress.enable_steady_tick(Duration::from_millis(100));
progress.set_message(format!(
"downloading previous generation metadata: {}",
gen_id
@@ -102,7 +118,7 @@ impl BackupProgress {
/// Update progress bar about number of actual files found.
pub fn found_live_file(&self, filename: &Path) {
self.progress.inc(1);
- if self.progress.length() < self.progress.position() {
+ if self.progress.length() < Some(self.progress.position()) {
self.progress.set_length(self.progress.position());
}
self.progress.set_message(format!("{}", filename.display()));
diff --git a/src/cipher.rs b/src/cipher.rs
index 7bd2e84..21785b9 100644
--- a/src/cipher.rs
+++ b/src/cipher.rs
@@ -4,7 +4,7 @@ use crate::chunk::DataChunk;
use crate::chunkmeta::ChunkMeta;
use crate::passwords::Passwords;
-use aes_gcm::aead::{generic_array::GenericArray, Aead, NewAead, Payload};
+use aes_gcm::aead::{generic_array::GenericArray, Aead, KeyInit, Payload};
use aes_gcm::Aes256Gcm; // Or `Aes128Gcm`
use rand::Rng;
diff --git a/src/cmd/init.rs b/src/cmd/init.rs
index 1310f66..5950fbb 100644
--- a/src/cmd/init.rs
+++ b/src/cmd/init.rs
@@ -20,7 +20,7 @@ impl Init {
pub fn run(&self, config: &ClientConfig) -> Result<(), ObnamError> {
let passphrase = match &self.insecure_passphrase {
Some(x) => x.to_string(),
- None => rpassword::read_password_from_tty(Some(PROMPT)).unwrap(),
+ None => rpassword::prompt_password(PROMPT).unwrap(),
};
let passwords = Passwords::new(&passphrase);
diff --git a/src/cmd/restore.rs b/src/cmd/restore.rs
index dff72fa..58caf61 100644
--- a/src/cmd/restore.rs
+++ b/src/cmd/restore.rs
@@ -306,6 +306,10 @@ fn create_progress_bar(file_count: FileId, verbose: bool) -> ProgressBar {
"current: {wide_msg}",
"{spinner}",
];
- progress.set_style(ProgressStyle::default_bar().template(&parts.join("\n")));
+ progress.set_style(
+ ProgressStyle::default_bar()
+ .template(&parts.join("\n"))
+ .expect("create indicatif ProgressStyle value"),
+ );
progress
}
diff --git a/src/passwords.rs b/src/passwords.rs
index ea476bf..efc3f96 100644
--- a/src/passwords.rs
+++ b/src/passwords.rs
@@ -76,7 +76,7 @@ fn derive_password(passphrase: &str) -> String {
let salt = SaltString::generate(&mut OsRng);
Pbkdf2
- .hash_password(passphrase.as_bytes(), salt.as_ref())
+ .hash_password(passphrase.as_bytes(), salt.as_salt())
.unwrap()
.to_string()
}