Skip to content

Commit a702acb

Browse files
committed
fix(reverts): results for the future
1 parent e2c3123 commit a702acb

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/otp/migrations/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
use super::otp_element::OTPDatabase;
22
struct Migration<'a> {
33
to_version: u16, // Database version which we are migrating on
4-
migration_function: &'a dyn Fn(&mut OTPDatabase), // Function to execute the migration
4+
migration_function: &'a dyn Fn(&mut OTPDatabase) -> color_eyre::Result<()>, // Function to execute the migration
55
}
66
const MIGRATIONS_LIST: [Migration; 1] = [Migration {
77
to_version: 2,
88
migration_function: &migrate_to_2,
99
}];
1010

11-
fn migrate_to_2(database: &mut OTPDatabase) {
11+
fn migrate_to_2(database: &mut OTPDatabase) -> color_eyre::Result<()> {
1212
database.version = 2;
13+
Ok(())
1314
}
1415

15-
pub fn migrate(database: &mut OTPDatabase) {
16+
pub fn migrate(database: &mut OTPDatabase) -> color_eyre::Result<()> {
1617
let mut binding = MIGRATIONS_LIST;
1718
let migrations = binding.as_mut();
1819
migrations.sort_unstable_by(|c1, c2| c1.to_version.cmp(&c2.to_version));
1920
for i in migrations {
2021
if database.version < i.to_version {
2122
// Do the migration
22-
(i.migration_function)(database);
23+
(i.migration_function)(database)?;
2324
}
2425
}
26+
Ok(())
2527
}

src/otp/otp_element.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl OTPDatabase {
5959

6060
pub fn save(&mut self, key: &Vec<u8>, salt: &[u8]) -> color_eyre::Result<()> {
6161
self.needs_modification = false;
62-
migrate(self);
62+
migrate(self)?;
6363
match self.overwrite_database_key(key, salt) {
6464
Ok(()) => Ok(()),
6565
Err(e) => Err(ErrReport::from(e)),

0 commit comments

Comments
 (0)