2021-11-25 15:36:30 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-11-19 00:02:35 +08:00
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading.Tasks;
|
2021-11-25 15:36:30 +08:00
|
|
|
using osu.Framework.Platform;
|
2022-11-19 00:02:35 +08:00
|
|
|
using osu.Game.Extensions;
|
2022-11-21 17:58:01 +08:00
|
|
|
using osu.Game.Overlays;
|
2021-11-25 15:36:30 +08:00
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Database
|
|
|
|
{
|
2022-11-17 22:38:24 +08:00
|
|
|
public class LegacyScoreExporter : LegacyModelExporter<ScoreInfo>
|
2021-11-25 15:36:30 +08:00
|
|
|
{
|
2022-11-21 17:58:01 +08:00
|
|
|
public LegacyScoreExporter(Storage storage, RealmAccess realm, INotificationOverlay? notifications = null)
|
|
|
|
: base(storage, realm, notifications)
|
2021-11-25 15:36:30 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-11-21 17:58:01 +08:00
|
|
|
protected override string FileExtension => ".osr";
|
|
|
|
|
|
|
|
public override async Task ExportToStreamAsync(ScoreInfo uuid, Stream stream)
|
2022-11-19 00:02:35 +08:00
|
|
|
{
|
|
|
|
await Task.Run(() =>
|
|
|
|
{
|
|
|
|
RealmAccess.Run(r =>
|
|
|
|
{
|
2022-11-21 17:58:01 +08:00
|
|
|
ScoreInfo model = r.Find<ScoreInfo>(uuid.ID);
|
|
|
|
|
2022-11-19 00:02:35 +08:00
|
|
|
var file = model.Files.SingleOrDefault();
|
|
|
|
if (file == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
using (var inputStream = UserFileStorage.GetStream(file.File.GetStoragePath()))
|
2022-11-21 17:58:01 +08:00
|
|
|
inputStream.CopyTo(stream);
|
2022-11-19 00:02:35 +08:00
|
|
|
});
|
|
|
|
}).ContinueWith(OnComplete);
|
|
|
|
}
|
2021-11-25 15:36:30 +08:00
|
|
|
}
|
|
|
|
}
|