limit date appending to LegacyScoreExporter only

This commit is contained in:
integer
2022-12-23 23:01:04 +00:00
parent b06a7daf26
commit 498d00935b
3 changed files with 22 additions and 2 deletions

View File

@ -3,11 +3,13 @@
#nullable disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using osu.Framework.Platform;
using osu.Game.Extensions;
using osu.Game.Scoring;
using osu.Game.Utils;
namespace osu.Game.Database
{
@ -15,9 +17,27 @@ namespace osu.Game.Database
{
protected override string FileExtension => ".osr";
private readonly Storage exportStorage;
public LegacyScoreExporter(Storage storage)
: base(storage)
{
exportStorage = storage.GetStorageForDirectory(@"exports");
}
private string GetScoreExportString(ScoreInfo score) => $"{score.GetDisplayString()} ({score.Date.LocalDateTime:yyyy-MM-dd})";
public override void Export(ScoreInfo score)
{
string scoreExportTitle = GetScoreExportString(score).GetValidFilename();
IEnumerable<string> existingExports = exportStorage.GetFiles("", $"{scoreExportTitle}*{FileExtension}");
string scoreExportFilename = NamingUtils.GetNextBestFilename(existingExports, $"{scoreExportTitle}{FileExtension}");
using (var stream = exportStorage.CreateFileSafely(scoreExportFilename))
ExportModelTo(score, stream);
exportStorage.PresentFileExternally(scoreExportFilename);
}
public override void ExportModelTo(ScoreInfo model, Stream outputStream)