fix(content): preserve instance data and isolate provider caches
This commit is contained in:
1 parent
978fd3e971
commit
9d480f8bfb
11 files changed
+209
-155
No files matched your search
@@ -101,8 +101,7 @@ pub async fn install(
|
||||
for item in &plan.items {
|
||||
tokio::fs::create_dir_all(&item.destination).await?;
|
||||
}
|
||||
let staging = staging_directory(minecraft_dir);
|
||||
tokio::fs::create_dir(&staging).await?;
|
||||
let staging = create_staging_directory(minecraft_dir).await?;
|
||||
|
||||
let result = install_staged(registry, manifest_path, minecraft_dir, &staging, plan).await;
|
||||
if let Err(error) = tokio::fs::remove_dir_all(&staging).await
|
||||
@@ -128,6 +127,17 @@ fn staging_directory(minecraft_dir: &Path) -> PathBuf {
|
||||
))
|
||||
}
|
||||
|
||||
async fn create_staging_directory(minecraft_dir: &Path) -> Result<PathBuf, NetError> {
|
||||
loop {
|
||||
let staging = staging_directory(minecraft_dir);
|
||||
match tokio::fs::create_dir(&staging).await {
|
||||
Ok(()) => return Ok(staging),
|
||||
Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists => continue,
|
||||
Err(error) => return Err(error.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct StagedFile {
|
||||
item: usize,
|
||||
source: PathBuf,
|
||||
|
||||
Reference in new issue
Block a user