From 6adac853e85f7ebf81f61fa90a3d3afc8f556d0a Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Sun, 27 Nov 2022 09:58:54 +0900 Subject: [PATCH] Spite sync method `ExportToStream` `uuid` to `model` --- osu.Game/Database/LegacyModelExporter.cs | 14 ++++++++------ osu.Game/Database/LegacyScoreExporter.cs | 21 ++++++--------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/osu.Game/Database/LegacyModelExporter.cs b/osu.Game/Database/LegacyModelExporter.cs index 3780f2b9cc..3523d18f29 100644 --- a/osu.Game/Database/LegacyModelExporter.cs +++ b/osu.Game/Database/LegacyModelExporter.cs @@ -74,24 +74,26 @@ namespace osu.Game.Database } /// - /// Export te model corresponding to uuid to given stream. + /// Export te model corresponding to model to given stream. /// - /// The medel which have . + /// The medel which have . /// The stream to export. /// - public virtual async Task ExportToStreamAsync(TModel uuid, Stream stream) + public async Task ExportToStreamAsync(TModel model, Stream stream) { - Guid id = uuid.ID; + Guid id = model.ID; await Task.Run(() => { RealmAccess.Run(r => { - TModel model = r.Find(id); - createZipArchive(model, stream); + TModel refetchModel = r.Find(id); + ExportToStream(refetchModel, stream); }); }).ContinueWith(OnComplete); } + protected virtual void ExportToStream(TModel model, Stream outputStream) => createZipArchive(model, outputStream); + private void createZipArchive(TModel model, Stream outputStream) { using (var archive = ZipArchive.Create()) diff --git a/osu.Game/Database/LegacyScoreExporter.cs b/osu.Game/Database/LegacyScoreExporter.cs index ae0fbf8d19..eb46bc6db2 100644 --- a/osu.Game/Database/LegacyScoreExporter.cs +++ b/osu.Game/Database/LegacyScoreExporter.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; -using System.Threading.Tasks; using osu.Framework.Platform; using osu.Game.Extensions; using osu.Game.Overlays; @@ -20,22 +19,14 @@ namespace osu.Game.Database protected override string FileExtension => ".osr"; - public override async Task ExportToStreamAsync(ScoreInfo uuid, Stream stream) + protected override void ExportToStream(ScoreInfo model, Stream stream) { - await Task.Run(() => - { - RealmAccess.Run(r => - { - ScoreInfo model = r.Find(uuid.ID); + var file = model.Files.SingleOrDefault(); + if (file == null) + return; - var file = model.Files.SingleOrDefault(); - if (file == null) - return; - - using (var inputStream = UserFileStorage.GetStream(file.File.GetStoragePath())) - inputStream.CopyTo(stream); - }); - }).ContinueWith(OnComplete); + using (var inputStream = UserFileStorage.GetStream(file.File.GetStoragePath())) + inputStream.CopyTo(stream); } } }