osukey/osu.Game/Database/LegacyScoreExporter.cs
cdwcgt e1a21e0cf9
create a task to export to avoid block main thread
Code quality and remove some #nullable disable
2022-11-17 01:08:06 +09:00

37 lines
1.1 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.IO;
using System.Linq;
using osu.Framework.Platform;
using osu.Game.Extensions;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Scoring;
namespace osu.Game.Database
{
public class LegacyScoreExporter : LegacyExporter<ScoreInfo>
{
protected override string FileExtension => ".osr";
public LegacyScoreExporter(Storage storage, INotificationOverlay? notificationOverlay)
: base(storage, notificationOverlay)
{
}
public override void ExportModelTo(ScoreInfo model, Stream outputStream)
{
var file = model.Files.SingleOrDefault();
if (file == null)
return;
using (var inputStream = UserFileStorage.GetStream(file.File.GetStoragePath()))
inputStream.CopyTo(outputStream);
Notification.State = ProgressNotificationState.Completed;
outputStream.Dispose();
}
}
}