BedrockLauncher.ViewModels.GameManager.ExtractPackage C# (CSharp) Метод

ExtractPackage() приватный Метод

private ExtractPackage ( BLVersion v, string dlPath, CancellationTokenSource cancelSource ) : Task
v BLVersion
dlPath string
cancelSource CancellationTokenSource
Результат Task
        private async Task ExtractPackage(BLVersion v, string dlPath, CancellationTokenSource cancelSource)
        {
            Stream zipReadingStream = null;
            try
            {
                System.Diagnostics.Debug.WriteLine("Extraction started");
                ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.isExtracting;
                ViewModels.LauncherModel.Default.CurrentProgress = 0;
                string dirPath = v.GameDirectory;
                if (Directory.Exists(dirPath))
                    Directory.Delete(dirPath, true);

                zipReadingStream = File.OpenRead(dlPath);
                ZipArchive zip = new ZipArchive(zipReadingStream);
                var progress = new Progress<ZipProgress>();
                progress.ProgressChanged += (s, z) =>
                {
                    ViewModels.LauncherModel.Default.CurrentProgress = z.Processed;
                    ViewModels.LauncherModel.Default.TotalProgress = z.Total;
                };
                await Task.Run(() => zip.ExtractToDirectory(dirPath, progress, cancelSource));

                zipReadingStream.Close();

                File.Delete(Path.Combine(dirPath, "AppxSignature.p7x"));
                File.Delete(dlPath);
                System.Diagnostics.Debug.WriteLine("Extracted successfully");
            }
            catch (TaskCanceledException e)
            {
                if (zipReadingStream != null) zipReadingStream.Close();
                Directory.Delete(v.GameDirectory, true);
                throw e;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Extraction failed:\n" + e.ToString());
                ErrorScreenShow.errormsg("Error_AppExtractionFailed_Title", "Error_AppExtractionFailed", e);
                if (zipReadingStream != null) zipReadingStream.Close();
                ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.None;
                throw new TaskCanceledException();
            }
        }