Skip to content

Commit

Permalink
Prompt for database save if user modifies HOTP counter (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
replydev authored Sep 12, 2024
2 parents dbb04c2 + d542a11 commit bf7ac56
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ debug = false
strip = "symbols"

[dependencies]
serde_json = "1.0.127"
serde = { version = "1.0.209", features = ["derive"] }
serde_json = "1.0.128"
serde = { version = "1.0.210", features = ["derive"] }
dirs = "5.0.1"
rpassword = "7.3.1"
data-encoding = "2.6.0"
copypasta-ext = "0.4.4"
zeroize = { version = "1.8.1", features = ["zeroize_derive"] }
clap = { version = "4.5.16", features = ["derive"] }
clap = { version = "4.5.17", features = ["derive"] }
hmac = "0.12.1"
sha1 = "0.10.6"
sha2 = "0.10.8"
Expand Down
1 change: 1 addition & 0 deletions src/interface/handlers/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ fn handle_counter_switch(app: &mut App, increment: bool) {
} else {
Some(counter.saturating_sub(1))
};
app.database.mark_modified();
app.tick(true);
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/otp/migrations/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use super::otp_element::OTPDatabase;

pub struct Migration<'a> {
struct Migration<'a> {
to_version: u16, // Database version which we are migrating on
migration_function: &'a dyn Fn(&mut OTPDatabase) -> color_eyre::Result<()>, // Function to execute the migration
}

pub const MIGRATIONS_LIST: [Migration; 1] = [Migration {
const MIGRATIONS_LIST: [Migration; 1] = [Migration {
to_version: 2,
migration_function: &migrate_to_2,
}];
Expand Down
3 changes: 1 addition & 2 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn get_default_db_path() -> PathBuf {
data_dir()
.map(PathBuf::from)
.map(|p| p.join(XDG_PATH))
.map(|xdg| {
.inspect(|xdg| {
if !xdg.exists() {
if let Some(home) = &home_path {
if home.exists() {
Expand All @@ -49,7 +49,6 @@ fn get_default_db_path() -> PathBuf {
}
}
}
xdg
})
.or(home_path)
.unwrap_or(portable_path)
Expand Down

0 comments on commit bf7ac56

Please sign in to comment.