mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
limit date appending to LegacyScoreExporter
only
This commit is contained in:
parent
b06a7daf26
commit
498d00935b
@ -37,7 +37,7 @@ namespace osu.Game.Database
|
|||||||
/// Exports an item to a legacy (.zip based) package.
|
/// Exports an item to a legacy (.zip based) package.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item to export.</param>
|
/// <param name="item">The item to export.</param>
|
||||||
public void Export(TModel item)
|
public virtual void Export(TModel item)
|
||||||
{
|
{
|
||||||
string itemFilename = item.GetDisplayString().GetValidFilename();
|
string itemFilename = item.GetDisplayString().GetValidFilename();
|
||||||
|
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
{
|
{
|
||||||
@ -15,9 +17,27 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
protected override string FileExtension => ".osr";
|
protected override string FileExtension => ".osr";
|
||||||
|
|
||||||
|
private readonly Storage exportStorage;
|
||||||
|
|
||||||
public LegacyScoreExporter(Storage storage)
|
public LegacyScoreExporter(Storage storage)
|
||||||
: base(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)
|
public override void ExportModelTo(ScoreInfo model, Stream outputStream)
|
||||||
|
@ -12,6 +12,6 @@ namespace osu.Game.Scoring
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A user-presentable display title representing this score.
|
/// A user-presentable display title representing this score.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetDisplayTitle(this IScoreInfo scoreInfo) => $"{scoreInfo.User.Username} playing {scoreInfo.Beatmap.GetDisplayTitle()} ({scoreInfo.Date.LocalDateTime:yyyy-MM-dd})";
|
public static string GetDisplayTitle(this IScoreInfo scoreInfo) => $"{scoreInfo.User.Username} playing {scoreInfo.Beatmap.GetDisplayTitle()}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user