diff --git a/osu.Game/Database/LegacyArchiveExporter.cs b/osu.Game/Database/LegacyArchiveExporter.cs index d37f9a5dca..01d00b311d 100644 --- a/osu.Game/Database/LegacyArchiveExporter.cs +++ b/osu.Game/Database/LegacyArchiveExporter.cs @@ -17,6 +17,9 @@ using Logger = osu.Framework.Logging.Logger; namespace osu.Game.Database { + /// + /// An exporter which handles the common scenario of exporting a model to a zip-based archive, usually with a custom file extension. + /// public abstract class LegacyArchiveExporter : LegacyExporter where TModel : RealmObject, IHasNamedFiles, IHasGuidPrimaryKey { @@ -31,17 +34,18 @@ namespace osu.Game.Database /// /// Exports an item to Stream as a legacy (.zip based) package. /// - /// The model will be exported. + /// The model to be exported. /// The output stream to export to. - /// The notification will displayed to the user - /// The Cancellation token that can cancel the exporting. + /// An optional target notification to update with ongoing export progress. + /// The cancellation token. private void exportZipArchive(TModel model, Stream outputStream, ProgressNotification? notification, CancellationToken cancellationToken = default) { try { using var writer = new ZipWriter(outputStream, new ZipWriterOptions(CompressionType.Deflate)); - float i = 0; + int i = 0; + int fileCount = model.Files.Count(); bool fileMissing = false; foreach (var file in model.Files) @@ -66,13 +70,12 @@ namespace osu.Game.Database } } - i++; - if (notification != null) { - notification.Progress = i / model.Files.Count(); - notification.Text = $"Exporting... ({i}/{model.Files.Count()})"; + notification.Progress = (float)(i + 1) / fileCount; } + + i++; } } catch (ObjectDisposedException)