1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Fix overwriting existing files

https://github.com/ppy/osu/pull/21468
This commit is contained in:
cdwcgt 2022-12-09 23:41:07 +09:00
parent a1fc33668c
commit 19afce6776
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@ -11,6 +12,7 @@ using osu.Framework.Platform;
using osu.Game.Extensions;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Utils;
using Realms;
using SharpCompress.Archives.Zip;
@ -64,7 +66,11 @@ namespace osu.Game.Database
{
if (item is TModel model)
{
filename = $"{model.GetDisplayString().GetValidFilename()}{FileExtension}";
string itemFilename = item.GetDisplayString().GetValidFilename();
IEnumerable<string> existingExports = ExportStorage.GetFiles("", $"{itemFilename}*{FileExtension}");
string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}");
using (var stream = ExportStorage.CreateFileSafely(filename))
{