Skip to content

Commit 1e45aad

Browse files
committed
fix: address Windows filename issues
Use underscore instead of colon or dots since they are not allowed in filenames in Windows. This is are some of the fixes required for Windows support which gets introduced/tested in the CI overhaul PR #253.
1 parent 3884314 commit 1e45aad

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

dash-spv/src/chain/chainlock_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl ChainLockManager {
333333
}
334334

335335
// Store persistently
336-
let key = format!("chainlock:{}", chain_lock.block_height);
336+
let key = format!("chainlock_{}", chain_lock.block_height);
337337
let data = bincode::serialize(&chain_lock)
338338
.map_err(|e| StorageError::Serialization(e.to_string()))?;
339339
storage.store_metadata(&key, &data).await?;

dash-spv/src/storage/io.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn get_temp_path(path: &Path) -> PathBuf {
1414
let file_name = path.file_name().and_then(|n| n.to_str()).unwrap_or("temp");
1515
let unique_id = COUNTER.fetch_add(1, Ordering::Relaxed);
1616
let pid = std::process::id();
17-
temp_path.set_file_name(format!(".{}.{}.{}.tmp", file_name, pid, unique_id));
17+
temp_path.set_file_name(format!("tmp_{}_{}_{}_.tmp", file_name, pid, unique_id));
1818
temp_path
1919
}
2020

@@ -75,10 +75,10 @@ mod tests {
7575
// Check temp file is in same directory as original
7676
assert_eq!(temp1.parent(), path.parent());
7777

78-
// Check temp file name starts with dot and ends with .tmp
78+
// Check temp file name starts with tmp_ and ends with .tmp
7979
let file_name = temp1.file_name().unwrap().to_string_lossy();
80-
assert!(file_name.starts_with(".file.dat."));
81-
assert!(file_name.ends_with(".tmp"));
80+
assert!(file_name.starts_with("tmp_file.dat_"));
81+
assert!(file_name.ends_with("_.tmp"));
8282
}
8383

8484
#[tokio::test]

0 commit comments

Comments
 (0)