working with test

This commit is contained in:
cdwcgt
2022-11-19 01:02:35 +09:00
parent 4b29941b47
commit fc4a6cb125
6 changed files with 113 additions and 88 deletions

View File

@ -1,7 +1,11 @@
// 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 System.Threading.Tasks;
using osu.Framework.Platform;
using osu.Game.Extensions;
using osu.Game.Overlays.Notifications;
using osu.Game.Scoring;
@ -11,22 +15,42 @@ namespace osu.Game.Database
{
protected override string FileExtension => ".osr";
public LegacyScoreExporter(Storage storage, RealmAccess realm, ProgressNotification notification)
: base(storage, realm, notification)
public LegacyScoreExporter(Storage storage, RealmAccess realm, ProgressNotification notification, Stream? stream = null)
: base(storage, realm, notification, stream)
{
}
//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();
//}
public override async Task ExportASync(IHasGuidPrimaryKey uuid)
{
await Task.Run(() =>
{
RealmAccess.Run(r =>
{
if (r.Find<ScoreInfo>(uuid.ID) is IHasNamedFiles model)
{
Filename = $"{model.GetDisplayString().GetValidFilename()}{FileExtension}";
}
else
{
return;
}
var file = model.Files.SingleOrDefault();
if (file == null)
return;
if (Notification.CancellationToken.IsCancellationRequested) return;
if (OutputStream == null)
{
OutputStream = ExportStorage.CreateFileSafely(Filename);
ShouldDisposeStream = true;
}
using (var inputStream = UserFileStorage.GetStream(file.File.GetStoragePath()))
inputStream.CopyTo(OutputStream);
});
}).ContinueWith(OnComplete);
}
}
}