Skip to content

Commit

Permalink
update installers
Browse files Browse the repository at this point in the history
  • Loading branch information
natsurainko committed Aug 28, 2024
1 parent c8eb829 commit 2b0c020
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ async Task<VanillaMinecraftInstance> ParseOrInstallVanillaInstance(CancellationT
McVersionManifestItem = McVersionManifestItem,
MinecraftFolder = MinecraftFolder,
CheckAllDependencies = true,
Progress = VanillaInstallationProgress
Progress = VanillaInstallationProgress,
CleanAfterCancelled = false
};

var instance = await vanillaInstanceInstaller.InstallAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ async Task<VanillaMinecraftInstance> ParseOrInstallVanillaInstance(CancellationT
McVersionManifestItem = McVersionManifestItem,
MinecraftFolder = MinecraftFolder,
CheckAllDependencies = true,
Progress = VanillaInstallationProgress
Progress = VanillaInstallationProgress,
CleanAfterCancelled = false
};

var instance = await vanillaInstanceInstaller.InstallAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ async Task<VanillaMinecraftInstance> ParseOrInstallVanillaInstance(CancellationT
McVersionManifestItem = McVersionManifestItem,
MinecraftFolder = MinecraftFolder,
CheckAllDependencies = true,
Progress = VanillaInstallationProgress
Progress = VanillaInstallationProgress,
CleanAfterCancelled = false
};

var instance = await vanillaInstanceInstaller.InstallAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ async Task<VanillaMinecraftInstance> ParseOrInstallVanillaInstance(CancellationT
McVersionManifestItem = McVersionManifestItem,
MinecraftFolder = MinecraftFolder,
CheckAllDependencies = true,
Progress = VanillaInstallationProgress
Progress = VanillaInstallationProgress,
CleanAfterCancelled = false
};

var instance = await vanillaInstanceInstaller.InstallAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class VanillaInstanceInstaller : IInstanceInstaller

public IProgress<InstallerProgress<VanillaInstallationStage>>? Progress { get; init; }

public bool CleanAfterCancelled { get; init; } = true;

Task<MinecraftInstance> IInstanceInstaller.InstallAsync(CancellationToken cancellationToken)
=> InstallAsync(cancellationToken).ContinueWith(MinecraftInstance (t) => t.Result);

Expand All @@ -55,13 +57,15 @@ public async Task<VanillaMinecraftInstance> InstallAsync(CancellationToken cance
catch (OperationCanceledException)
{
// 取消后清理产生的部分文件

assetIndex?.Delete();

if (instance != null)
if (CleanAfterCancelled)
{
versionJsonFile!.Directory?.DeleteAllFiles();
versionJsonFile!.Directory?.Delete();
assetIndex?.Delete();

if (instance != null)
{
versionJsonFile!.Directory?.DeleteAllFiles();
versionJsonFile!.Directory?.Delete();
}
}

Progress?.Report(new(stage, InstallerStageProgress.Failed()));
Expand Down

0 comments on commit 2b0c020

Please sign in to comment.