From 4ccfebc02be0c0c1275d8ae76344f11d18be1a79 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 May 2023 21:01:10 +0900 Subject: [PATCH] Simplify `ExportToStreamAsync` implementation --- osu.Game/Database/LegacyExporter.cs | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index e5df2a4337..bc86420cd2 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -7,7 +7,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using osu.Framework.Logging; using osu.Framework.Platform; using osu.Game.Extensions; using osu.Game.Overlays.Notifications; @@ -159,30 +158,8 @@ namespace osu.Game.Database /// The notification will displayed to the user /// The Cancellation token that can cancel the exporting. /// Whether the export was successful - public Task ExportToStreamAsync(Live model, Stream stream, ProgressNotification? notification = null, CancellationToken cancellationToken = default) - { - return Task.Run(() => - { - model.PerformRead(s => - { - ExportToStream(s, stream, notification, cancellationToken); - }); - }, cancellationToken).ContinueWith(t => - { - if (cancellationToken.IsCancellationRequested) - { - return false; - } - - if (t.IsFaulted) - { - Logger.Error(t.Exception, "An error occurred while exporting", LoggingTarget.Database); - throw t.Exception!; - } - - return true; - }, CancellationToken.None); - } + public Task ExportToStreamAsync(Live model, Stream stream, ProgressNotification? notification = null, CancellationToken cancellationToken = default) => + Task.Run(() => { model.PerformRead(s => ExportToStream(s, stream, notification, cancellationToken)); }, cancellationToken); /// /// Exports model to Stream.