Delete install path on install error

This commit is contained in:
Daniel 2023-04-08 15:47:01 -05:00
parent cb770f8dab
commit f05005460f

View file

@ -102,25 +102,35 @@ namespace LANCommander.PlaynitePlugin
Plugin.PlayniteApi.Dialogs.ActivateGlobalProgress(progress => Plugin.PlayniteApi.Dialogs.ActivateGlobalProgress(progress =>
{ {
Directory.CreateDirectory(destination); try
progress.ProgressMaxValue = 100;
progress.CurrentProgressValue = 0;
using (var gameStream = Plugin.LANCommander.StreamGame(game.Id))
using (var reader = ReaderFactory.Open(gameStream))
{ {
progress.ProgressMaxValue = gameStream.Length; Directory.CreateDirectory(destination);
progress.ProgressMaxValue = 100;
progress.CurrentProgressValue = 0;
gameStream.OnProgress += (pos, len) => using (var gameStream = Plugin.LANCommander.StreamGame(game.Id))
using (var reader = ReaderFactory.Open(gameStream))
{ {
progress.CurrentProgressValue = pos; progress.ProgressMaxValue = gameStream.Length;
};
reader.WriteAllToDirectory(destination, new ExtractionOptions() gameStream.OnProgress += (pos, len) =>
{
progress.CurrentProgressValue = pos;
};
reader.WriteAllToDirectory(destination, new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
}
}
catch (Exception ex)
{
if (Directory.Exists(destination))
{ {
ExtractFullPath = true, Directory.Delete(destination, true);
Overwrite = true }
});
} }
}, },
new GlobalProgressOptions($"Downloading {game.Title}...") new GlobalProgressOptions($"Downloading {game.Title}...")