From b06a7daf26e3656e10346b2059aa0800bab00cdb Mon Sep 17 00:00:00 2001
From: integer <7279624+integerrr@users.noreply.github.com>
Date: Tue, 20 Dec 2022 23:40:00 +0000
Subject: [PATCH 1/5] append date to score export filename
---
osu.Game/Scoring/ScoreInfoExtensions.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Scoring/ScoreInfoExtensions.cs b/osu.Game/Scoring/ScoreInfoExtensions.cs
index 7979ca8aaa..3cfdbe87c3 100644
--- a/osu.Game/Scoring/ScoreInfoExtensions.cs
+++ b/osu.Game/Scoring/ScoreInfoExtensions.cs
@@ -12,6 +12,6 @@ namespace osu.Game.Scoring
///
/// A user-presentable display title representing this score.
///
- public static string GetDisplayTitle(this IScoreInfo scoreInfo) => $"{scoreInfo.User.Username} playing {scoreInfo.Beatmap.GetDisplayTitle()}";
+ public static string GetDisplayTitle(this IScoreInfo scoreInfo) => $"{scoreInfo.User.Username} playing {scoreInfo.Beatmap.GetDisplayTitle()} ({scoreInfo.Date.LocalDateTime:yyyy-MM-dd})";
}
}
From 498d00935bff763f0d5a7fcb5344f177e510ddb6 Mon Sep 17 00:00:00 2001
From: integer <7279624+integerrr@users.noreply.github.com>
Date: Fri, 23 Dec 2022 23:01:04 +0000
Subject: [PATCH 2/5] limit date appending to `LegacyScoreExporter` only
---
osu.Game/Database/LegacyExporter.cs | 2 +-
osu.Game/Database/LegacyScoreExporter.cs | 20 ++++++++++++++++++++
osu.Game/Scoring/ScoreInfoExtensions.cs | 2 +-
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs
index 374f9f557a..02219c4dfa 100644
--- a/osu.Game/Database/LegacyExporter.cs
+++ b/osu.Game/Database/LegacyExporter.cs
@@ -37,7 +37,7 @@ namespace osu.Game.Database
/// Exports an item to a legacy (.zip based) package.
///
/// The item to export.
- public void Export(TModel item)
+ public virtual void Export(TModel item)
{
string itemFilename = item.GetDisplayString().GetValidFilename();
diff --git a/osu.Game/Database/LegacyScoreExporter.cs b/osu.Game/Database/LegacyScoreExporter.cs
index 6fa02b957d..fc80693765 100644
--- a/osu.Game/Database/LegacyScoreExporter.cs
+++ b/osu.Game/Database/LegacyScoreExporter.cs
@@ -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 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)
diff --git a/osu.Game/Scoring/ScoreInfoExtensions.cs b/osu.Game/Scoring/ScoreInfoExtensions.cs
index 3cfdbe87c3..7979ca8aaa 100644
--- a/osu.Game/Scoring/ScoreInfoExtensions.cs
+++ b/osu.Game/Scoring/ScoreInfoExtensions.cs
@@ -12,6 +12,6 @@ namespace osu.Game.Scoring
///
/// A user-presentable display title representing this score.
///
- 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()}";
}
}
From d392d1a5c08daa0d3f857e75f1d18fbbb160138c Mon Sep 17 00:00:00 2001
From: integer <7279624+integerrr@users.noreply.github.com>
Date: Sat, 24 Dec 2022 22:18:42 +0000
Subject: [PATCH 3/5] override a sub-method instead of the whole `Export()`
---
osu.Game/Database/LegacyExporter.cs | 10 +++++-----
osu.Game/Database/LegacyScoreExporter.cs | 22 +++++-----------------
2 files changed, 10 insertions(+), 22 deletions(-)
diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs
index 02219c4dfa..3f305fb420 100644
--- a/osu.Game/Database/LegacyExporter.cs
+++ b/osu.Game/Database/LegacyExporter.cs
@@ -33,17 +33,17 @@ namespace osu.Game.Database
UserFileStorage = storage.GetStorageForDirectory(@"files");
}
+ protected virtual string GetItemExportString(TModel item) => item.GetDisplayString().GetValidFilename();
+
///
/// Exports an item to a legacy (.zip based) package.
///
/// The item to export.
- public virtual void Export(TModel item)
+ public void Export(TModel item)
{
- string itemFilename = item.GetDisplayString().GetValidFilename();
+ IEnumerable existingExports = exportStorage.GetFiles("", $"{GetItemExportString(item)}*{FileExtension}");
- IEnumerable existingExports = exportStorage.GetFiles("", $"{itemFilename}*{FileExtension}");
-
- string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}");
+ string filename = NamingUtils.GetNextBestFilename(existingExports, $"{GetItemExportString(item)}{FileExtension}");
using (var stream = exportStorage.CreateFileSafely(filename))
ExportModelTo(item, stream);
diff --git a/osu.Game/Database/LegacyScoreExporter.cs b/osu.Game/Database/LegacyScoreExporter.cs
index fc80693765..e176449fd0 100644
--- a/osu.Game/Database/LegacyScoreExporter.cs
+++ b/osu.Game/Database/LegacyScoreExporter.cs
@@ -3,13 +3,11 @@
#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
{
@@ -17,27 +15,17 @@ 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)
+ protected override string GetItemExportString(ScoreInfo score)
{
- string scoreExportTitle = GetScoreExportString(score).GetValidFilename();
-
- IEnumerable existingExports = exportStorage.GetFiles("", $"{scoreExportTitle}*{FileExtension}");
-
- string scoreExportFilename = NamingUtils.GetNextBestFilename(existingExports, $"{scoreExportTitle}{FileExtension}");
- using (var stream = exportStorage.CreateFileSafely(scoreExportFilename))
- ExportModelTo(score, stream);
-
- exportStorage.PresentFileExternally(scoreExportFilename);
+ string scoreString = score.GetDisplayString();
+ string filename = $"{scoreString} ({score.Date.LocalDateTime:yyyy-MM-dd})";
+
+ return filename.GetValidFilename();
}
public override void ExportModelTo(ScoreInfo model, Stream outputStream)
From 272288c9aa2e6b8a04be72392960ab9fe33ae3a0 Mon Sep 17 00:00:00 2001
From: integer <7279624+integerrr@users.noreply.github.com>
Date: Sun, 25 Dec 2022 21:50:56 +0000
Subject: [PATCH 4/5] fix code style and naming
---
osu.Game/Database/LegacyExporter.cs | 8 +++++---
osu.Game/Database/LegacyScoreExporter.cs | 6 +++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs
index 3f305fb420..09d6913dd9 100644
--- a/osu.Game/Database/LegacyExporter.cs
+++ b/osu.Game/Database/LegacyExporter.cs
@@ -33,7 +33,7 @@ namespace osu.Game.Database
UserFileStorage = storage.GetStorageForDirectory(@"files");
}
- protected virtual string GetItemExportString(TModel item) => item.GetDisplayString().GetValidFilename();
+ protected virtual string GetFilename(TModel item) => item.GetDisplayString();
///
/// Exports an item to a legacy (.zip based) package.
@@ -41,9 +41,11 @@ namespace osu.Game.Database
/// The item to export.
public void Export(TModel item)
{
- IEnumerable existingExports = exportStorage.GetFiles("", $"{GetItemExportString(item)}*{FileExtension}");
+ string itemFilename = GetFilename(item).GetValidFilename();
- string filename = NamingUtils.GetNextBestFilename(existingExports, $"{GetItemExportString(item)}{FileExtension}");
+ IEnumerable existingExports = exportStorage.GetFiles("", $"{itemFilename}*{FileExtension}");
+
+ string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}");
using (var stream = exportStorage.CreateFileSafely(filename))
ExportModelTo(item, stream);
diff --git a/osu.Game/Database/LegacyScoreExporter.cs b/osu.Game/Database/LegacyScoreExporter.cs
index e176449fd0..7c0ba7c6ee 100644
--- a/osu.Game/Database/LegacyScoreExporter.cs
+++ b/osu.Game/Database/LegacyScoreExporter.cs
@@ -20,12 +20,12 @@ namespace osu.Game.Database
{
}
- protected override string GetItemExportString(ScoreInfo score)
+ protected override string GetFilename(ScoreInfo score)
{
string scoreString = score.GetDisplayString();
string filename = $"{scoreString} ({score.Date.LocalDateTime:yyyy-MM-dd})";
-
- return filename.GetValidFilename();
+
+ return filename;
}
public override void ExportModelTo(ScoreInfo model, Stream outputStream)
From f971405c8c3978d6603461316f3d37ec8be105c6 Mon Sep 17 00:00:00 2001
From: integer <7279624+integerrr@users.noreply.github.com>
Date: Tue, 10 Jan 2023 00:02:31 +0000
Subject: [PATCH 5/5] append time as well
---
osu.Game/Database/LegacyScoreExporter.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Database/LegacyScoreExporter.cs b/osu.Game/Database/LegacyScoreExporter.cs
index 7c0ba7c6ee..01f9afdc86 100644
--- a/osu.Game/Database/LegacyScoreExporter.cs
+++ b/osu.Game/Database/LegacyScoreExporter.cs
@@ -23,7 +23,7 @@ namespace osu.Game.Database
protected override string GetFilename(ScoreInfo score)
{
string scoreString = score.GetDisplayString();
- string filename = $"{scoreString} ({score.Date.LocalDateTime:yyyy-MM-dd})";
+ string filename = $"{scoreString} ({score.Date.LocalDateTime:yyyy-MM-dd_HH-mm})";
return filename;
}