Skip to content

Commit 5cc5671

Browse files
Update FileSystemPersister to work with Windows.
Mainly, use std::path::Path so that the constructed paths are OS-agnostic. Also, Windows necessitates the use of OpenOptions with the `write` permission enabled to `sync_all` on a newly opened channel's data file.
1 parent 291f35b commit 5cc5671

File tree

1 file changed

+5
-1
lines changed
  • lightning-data-persister/src

1 file changed

+5
-1
lines changed

lightning-data-persister/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use lightning::chain::transaction::OutPoint;
99
use lightning::ln::data_persister::ChannelDataPersister;
1010
use lightning::util::ser::{Writeable, Readable};
1111
use std::fs;
12+
use std::path::Path;
1213
use std::io::Error;
1314
use std::marker::PhantomData;
1415
use std::path::Path;
@@ -60,7 +61,10 @@ impl<ChanSigner: ChannelKeys + Readable + Writeable> FilesystemPersister<ChanSig
6061
}
6162

6263
fn get_full_filepath(&self, funding_txo: OutPoint) -> String {
63-
format!("{}/{}_{}", self.path_to_channel_data, funding_txo.txid.to_hex(), funding_txo.index)
64+
let path = Path::new(&self.path_to_channel_data);
65+
let mut path_buf = path.to_path_buf();
66+
path_buf.push(format!("{}_{}", funding_txo.txid.to_hex(), funding_txo.index));
67+
path_buf.to_str().unwrap().to_string()
6468
}
6569

6670
// Utility to write a file to disk.

0 commit comments

Comments
 (0)