Skip to content

Commit 863108a

Browse files
committed
Fixing race condition in tests
1 parent ae16f8d commit 863108a

2 files changed

Lines changed: 77 additions & 39 deletions

File tree

vcs-worker/Cargo.lock

Lines changed: 59 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vcs-worker/src/git_backup.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ fn apply_meta_filtering(obj_content: &str, meta: &crate::types::MooMetaObject) -
291291

292292
/// Sanitize a filename by replacing invalid characters
293293
pub fn sanitize_filename(name: &str) -> String {
294-
name.replace('/', "_")
294+
let sanitized = name.replace('/', "_")
295295
.replace('\\', "_")
296296
.replace(':', "_")
297297
.replace('*', "_")
@@ -300,7 +300,23 @@ pub fn sanitize_filename(name: &str) -> String {
300300
.replace('<', "_")
301301
.replace('>', "_")
302302
.replace('|', "_")
303-
.replace('$', "")
303+
.replace('$', "");
304+
305+
// Collapse consecutive underscores into a single underscore
306+
let mut result = String::new();
307+
let mut last_was_underscore = false;
308+
for c in sanitized.chars() {
309+
if c == '_' {
310+
if !last_was_underscore {
311+
result.push(c);
312+
last_was_underscore = true;
313+
}
314+
} else {
315+
result.push(c);
316+
last_was_underscore = false;
317+
}
318+
}
319+
result
304320
}
305321

306322
/// Clean up old .moo files that no longer correspond to objects

0 commit comments

Comments
 (0)