Merge pull request #1686 from Domanffe/fix/launcher-remove-retry
Launcher: a version removal retries a locked file and leaves the UI thread
This commit is contained in:
+13
-1
@@ -558,7 +558,19 @@ pub fn install(release: &Release, progress: impl Fn(f32)) -> Result<(), String>
|
||||
}
|
||||
|
||||
pub fn remove(tag: &str) -> Result<(), String> {
|
||||
fs::remove_dir_all(version_dir(tag)).map_err(|e| e.to_string())
|
||||
let dir = version_dir(tag);
|
||||
// Windows holds a file for a moment after the game, a scan or the launcher's own reader lets
|
||||
// go of it, and remove_dir_all stops at the first one. Retry for a second; a folder that is
|
||||
// already gone is removed.
|
||||
for attempt in 1.. {
|
||||
match fs::remove_dir_all(&dir) {
|
||||
Ok(()) => break,
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => break,
|
||||
Err(e) if attempt == 5 => return Err(e.to_string()),
|
||||
Err(_) => std::thread::sleep(std::time::Duration::from_millis(250)),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The Minecraft version a Horizon build targets, from its research-lock.json.
|
||||
|
||||
Reference in New Issue
Block a user