Skip to content

Commit

Permalink
Merge pull request #2172 from get10101/fix/sync-on-upgrade
Browse files Browse the repository at this point in the history
Check for old wallet data in correct location
  • Loading branch information
luckysori committed Mar 6, 2024
2 parents ba17ed8 + b184698 commit 484faf6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mobile/native/src/ln_dlc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,18 @@ pub fn run(seed_dir: String, runtime: &Runtime) -> Result<()> {
pub async fn full_sync_on_wallet_db_migration() {
let node = state::get_node();

let old_wallet_db_path = Path::new(&config::get_data_dir()).join("wallet");
if old_wallet_db_path.exists() {
let old_wallet_dir = Path::new(&config::get_data_dir())
.join(config::get_network().to_string())
.join("on_chain");
if old_wallet_dir.exists() {
event::publish(&EventInternal::BackgroundNotification(
event::BackgroundTask::FullSync(event::TaskStatus::Pending),
));

let stop_gap = 20;
tracing::info!(
%stop_gap,
"Old wallet DB detected. Attempting to populate new wallet with full sync"
"Old wallet directory detected. Attempting to populate new wallet with full sync"
);

match node.inner.full_sync(stop_gap).await {
Expand All @@ -475,8 +477,8 @@ pub async fn full_sync_on_wallet_db_migration() {
event::BackgroundTask::FullSync(event::TaskStatus::Success),
));

if let Err(e) = std::fs::remove_file(old_wallet_db_path) {
tracing::info!("Failed to delete old wallet DB file: {e:#}");
if let Err(e) = std::fs::remove_dir_all(old_wallet_dir) {
tracing::info!("Failed to delete old wallet directory: {e:#}");
}
}
Err(e) => {
Expand Down

0 comments on commit 484faf6

Please sign in to comment.