From 5912dfd443effad317f5085aba57f4b380868d6e Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Thu, 15 Dec 2022 23:42:49 +0900 Subject: [PATCH] using declaration reshaper --- osu.Game/Database/LegacyModelExporter.cs | 49 ++++++++++++------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/osu.Game/Database/LegacyModelExporter.cs b/osu.Game/Database/LegacyModelExporter.cs index 531a6f48da..d896e4bce6 100644 --- a/osu.Game/Database/LegacyModelExporter.cs +++ b/osu.Game/Database/LegacyModelExporter.cs @@ -140,40 +140,39 @@ namespace osu.Game.Database /// The notification will displayed to the user private void exportZipArchive(TModel model, Stream outputStream, ProgressNotification notification) { - using (var writer = new ZipWriter(outputStream, new ZipWriterOptions(CompressionType.Deflate))) + using var writer = new ZipWriter(outputStream, new ZipWriterOptions(CompressionType.Deflate)); + + float i = 0; + bool fileMissing = false; + + foreach (var file in model.Files) { - float i = 0; - bool fileMissing = false; + notification.CancellationToken.ThrowIfCancellationRequested(); - foreach (var file in model.Files) + using (var stream = UserFileStorage.GetStream(file.File.GetStoragePath())) { - notification.CancellationToken.ThrowIfCancellationRequested(); - - using (var stream = UserFileStorage.GetStream(file.File.GetStoragePath())) + // Sometimes we cannot find the file(probably deleted by the user), so we handle this and post a error. + if (stream == null) { - // Sometimes we cannot find the file(probably deleted by the user), so we handle this and post a error. - if (stream == null) + // Only pop up once to prevent spam. + if (!fileMissing) { - // Only pop up once to prevent spam. - if (!fileMissing) + PostNotification?.Invoke(new SimpleErrorNotification { - PostNotification?.Invoke(new SimpleErrorNotification - { - Text = "Some of your files are missing, they will not be included in the archive" - }); - fileMissing = true; - } - } - else - { - writer.Write(file.Filename, stream); + Text = "Some of your files are missing, they will not be included in the archive" + }); + fileMissing = true; } } - - i++; - notification.Progress = i / model.Files.Count(); - notification.Text = $"Exporting... ({i}/{model.Files.Count()})"; + else + { + writer.Write(file.Filename, stream); + } } + + i++; + notification.Progress = i / model.Files.Count(); + notification.Text = $"Exporting... ({i}/{model.Files.Count()})"; } } }