Skip to content

Commit 72226a0

Browse files
committed
fix windows support by removing unsupported dir characters disassembler#9
1 parent 73fc9b8 commit 72226a0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/data_types.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,22 @@ pub struct DataDirMnemonic<'a> {
180180
pub deriv_index: u32,
181181
}
182182

183+
fn normalize_challenge_id(challenge_id: &str) -> String {
184+
#[cfg(target_os = "windows")]
185+
{
186+
// Directories with '*' are not supported on windows
187+
challenge_id.replace("*", "")
188+
}
189+
#[cfg(not(target_os = "windows"))]
190+
{
191+
challenge_id.to_string()
192+
}
193+
}
194+
183195
impl<'a> DataDir<'a> {
184196
pub fn challenge_dir(&'a self, base_dir: &str, challenge_id: &str) -> Result<PathBuf, String> {
185197
let mut path = PathBuf::from(base_dir);
186-
path.push(challenge_id);
198+
path.push(normalize_challenge_id(challenge_id));
187199
Ok(path)
188200
}
189201

@@ -263,7 +275,7 @@ impl<'a> DataDir<'a> {
263275
.map_err(|e| format!("Could not create pending_submissions directory: {}", e))?;
264276

265277
// Use a unique file name based on challenge, address, and nonce
266-
path.push(format!("{}_{}_{}.json", solution.address, solution.challenge_id, solution.nonce));
278+
path.push(format!("{}_{}_{}.json", solution.address, normalize_challenge_id(&solution.challenge_id), solution.nonce));
267279

268280
let solution_json = serde_json::to_string(solution)
269281
.map_err(|e| format!("Could not serialize pending solution: {}", e))?;
@@ -320,12 +332,12 @@ pub fn is_solution_pending_in_queue(base_dir: &str, address: &str, challenge_id:
320332
if let Some(filename) = entry.file_name().to_str() {
321333
// Check if the filename starts with the required prefix and is a JSON file
322334
// The filename format is: address_challenge_id_nonce.json
323-
if filename.starts_with(&format!("{}_{}_", address, challenge_id)) && filename.ends_with(".json") {
335+
if filename.starts_with(&format!("{}_{}_", address, normalize_challenge_id(&challenge_id))) && filename.ends_with(".json") {
324336
return Ok(true);
325337
}
326338
}
327339
}
328340
}
329341
// If the directory doesn't exist or no matching file is found
330342
Ok(false)
331-
}
343+
}

0 commit comments

Comments
 (0)