-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not delete target wallet, do not fail migration on item-error #1006
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ use aries_vcx::{ | |
base_wallet::BaseWallet, | ||
indy::{ | ||
internal::{close_search_wallet, fetch_next_records_wallet, open_search_wallet}, | ||
wallet::{close_wallet, create_and_open_wallet, delete_wallet, import}, | ||
wallet::{close_wallet, create_and_open_wallet, import}, | ||
IndySdkWallet, IssuerConfig, RestoreWalletConfigs, WalletConfig, | ||
}, | ||
structs_io::UnpackMessageOutput, | ||
|
@@ -282,7 +282,12 @@ pub async fn wallet_import(config: &RestoreWalletConfigs) -> LibvcxResult<()> { | |
|
||
pub async fn wallet_migrate(wallet_config: &WalletConfig) -> LibvcxResult<()> { | ||
let src_wallet_handle = get_main_wallet_handle()?; | ||
info!( | ||
"Creating or opening target wallet {}", | ||
&wallet_config.wallet_name | ||
); | ||
let dest_wallet_handle = create_and_open_wallet(wallet_config).await?; | ||
info!("Target wallet is ready."); | ||
|
||
let migration_res = wallet_migrator::migrate_wallet( | ||
src_wallet_handle, | ||
|
@@ -291,18 +296,11 @@ pub async fn wallet_migrate(wallet_config: &WalletConfig) -> LibvcxResult<()> { | |
) | ||
.await; | ||
|
||
if let Err(e) = migration_res { | ||
close_wallet(dest_wallet_handle).await.ok(); | ||
delete_wallet(wallet_config).await.ok(); | ||
Err(LibvcxError::from_msg( | ||
LibvcxErrorKind::WalletMigrationFailed, | ||
e, | ||
)) | ||
} else { | ||
setup_wallet(dest_wallet_handle)?; | ||
close_wallet(src_wallet_handle).await?; | ||
Ok(()) | ||
} | ||
Comment on lines
-294
to
-305
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not delete the destination wallet on failure? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to rerun migration against the same target repeatedly, with predictable result. If I get IO error midway, I want to be able to retry. |
||
info!("Closing source and target wallets"); | ||
close_wallet(src_wallet_handle).await.ok(); | ||
close_wallet(dest_wallet_handle).await.ok(); | ||
|
||
migration_res.map_err(|e| LibvcxError::from_msg(LibvcxErrorKind::WalletMigrationFailed, e)) | ||
} | ||
|
||
#[allow(clippy::unwrap_used)] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,6 +165,7 @@ impl Wallet { | |
name: &str, | ||
value: &str, | ||
tags: &HashMap<String, String>, | ||
cache_record: bool, | ||
) -> IndyResult<()> { | ||
let etype = encrypt_as_searchable( | ||
type_.as_bytes(), | ||
|
@@ -188,7 +189,9 @@ impl Wallet { | |
); | ||
|
||
self.storage.add(&etype, &ename, &evalue, &etags).await?; | ||
self.cache.add(type_, &etype, &ename, &evalue, &etags); | ||
if cache_record { | ||
self.cache.add(type_, &etype, &ename, &evalue, &etags); | ||
} | ||
Comment on lines
+192
to
+194
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this change supposed to do? I see the flag is set to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In migration, the flag is set to |
||
|
||
Ok(()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will always attempt to create it.