From 8f1d3eab4106bbebdbcc5aa71cf87e140ffe45be Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Wed, 29 May 2024 10:53:37 -0400 Subject: [PATCH] f terminate early if no deprecated spendables present --- src/sweep.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sweep.rs b/src/sweep.rs index 15da689..decaca0 100644 --- a/src/sweep.rs +++ b/src/sweep.rs @@ -1,5 +1,5 @@ use std::io::{Read, Seek, SeekFrom}; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::Arc; use std::{fs, io}; @@ -28,6 +28,14 @@ pub(crate) async fn migrate_deprecated_spendable_outputs( let processing_spendables_dir = format!("{}/processing_spendable_outputs", ldk_data_dir); let spendables_dir = format!("{}/spendable_outputs", ldk_data_dir); + if !Path::new(&pending_spendables_dir).exists() + && !Path::new(&processing_spendables_dir).exists() + && !Path::new(&spendables_dir).exists() + { + lightning::log_info!(&*logger, "No deprecated spendable outputs to migrate, returning"); + return; + } + if let Ok(dir_iter) = fs::read_dir(&pending_spendables_dir) { // Move any spendable descriptors from pending folder so that we don't have any // races with new files being added.