launcher: two Windows-only failures (server delete, a test's line ends)

- Deleting a stopped server always failed on Windows ("Access is denied"): the folder was
  moved while its lock file was open. The lock is released just before the move there; a
  supervisor starting in between holds it again and the move fails, so a live server stays.
- mojang_downloads_only_for_an_owner searched source text for "\n", which a Windows
  checkout writes as CRLF.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Ludovic MarieandClaude Opus 5.5 committed 2026-10-28 21:20:49 +01:00
1 parent 3782473f52
commit 9cdfc5bd44
2 files changed
+7 -1

No files matched your search

+2 -1
View File
@@ -2906,7 +2906,8 @@ mod tests {
let name = path.file_name().unwrap().to_string_lossy().to_string();
let in_tests = name.contains("tests") || path.parent().unwrap() != src;
// The code alone: test modules (this one included) come after it.
let mut text = fs::read_to_string(&path).unwrap();
// A Windows checkout has CRLF line ends: the searches below look for "\n".
let mut text = fs::read_to_string(&path).unwrap().replace("\r\n", "\n");
text.truncate(text.find("#[cfg(test)]").unwrap_or(text.len()));
sources.push((name, in_tests, text));
}
+5
View File
@@ -107,6 +107,11 @@ fn trash_stopped_server(
.map_err(|e| e.to_string())?;
lock.try_lock()
.map_err(|_| "Stop the server before deleting it.".to_string())?;
// Windows can't move a folder while a file in it is open, the lock included: let it go
// first. Still safe: a supervisor starting in between opens the lock again, and then the
// move fails instead of taking a live server.
#[cfg(windows)]
drop(lock);
trash(dir).map_err(|e| format!("Could not move the server to the trash: {e}"))
}