Skip to content

Commit 1440b44

Browse files
committed
Fix build on Windows
1 parent ad642fb commit 1440b44

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ esplora-client = { version = "0.4", default-features = false }
7070
libc = "0.2"
7171
uniffi = { version = "0.23.0", features = ["build"], optional = true }
7272

73+
[target.'cfg(windows)'.dependencies]
74+
winapi = { version = "0.3", features = ["winbase"] }
75+
7376
[dev-dependencies]
7477
electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_23_0"] }
7578
electrum-client = "0.12.0"

src/logger.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use lightning::util::ser::Writer;
77
use chrono::Utc;
88

99
use std::fs;
10+
#[cfg(not(target_os = "windows"))]
1011
use std::os::unix::fs::symlink;
1112
use std::path::Path;
1213

@@ -31,14 +32,18 @@ impl FilesystemLogger {
3132
.open(log_file_path.clone())
3233
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
3334

34-
// Create a symlink to the current log file, with prior cleanup
35-
let log_file_symlink = parent_dir.join("ldk_node_latest.log");
36-
if log_file_symlink.as_path().is_symlink() {
37-
fs::remove_file(&log_file_symlink)
38-
.map_err(|e| eprintln!("ERROR: Failed to remove log file symlink: {}", e))?;
35+
#[cfg(not(target_os = "windows"))]
36+
{
37+
// Create a symlink to the current log file, with prior cleanup
38+
let log_file_symlink = parent_dir.join("ldk_node_latest.log");
39+
if log_file_symlink.as_path().is_symlink() {
40+
fs::remove_file(&log_file_symlink).map_err(|e| {
41+
eprintln!("ERROR: Failed to remove log file symlink: {}", e)
42+
})?;
43+
}
44+
symlink(&log_file_name, &log_file_symlink)
45+
.map_err(|e| eprintln!("ERROR: Failed to create log file symlink: {}", e))?;
3946
}
40-
symlink(&log_file_name, &log_file_symlink)
41-
.map_err(|e| eprintln!("ERROR: Failed to create log file symlink: {}", e))?;
4247
}
4348

4449
Ok(Self { file_path: log_file_path, level })

0 commit comments

Comments
 (0)