mirror of
https://github.com/ppy/osu
synced 2025-03-05 02:49:30 +00:00
Bring truncating logic back to Export
method
This commit is contained in:
parent
322f3e86ba
commit
5191204569
@ -48,15 +48,7 @@ namespace osu.Game.Database
|
||||
UserFileStorage = storage.GetStorageForDirectory(@"files");
|
||||
}
|
||||
|
||||
protected virtual string GetFilename(TModel item)
|
||||
{
|
||||
string filename = item.GetDisplayString();
|
||||
|
||||
if (filename.Length > MAX_FILENAME_LENGTH - FileExtension.Length)
|
||||
return filename.Remove(MAX_FILENAME_LENGTH - FileExtension.Length);
|
||||
|
||||
return filename;
|
||||
}
|
||||
protected virtual string GetFilename(TModel item) => item.GetDisplayString();
|
||||
|
||||
/// <summary>
|
||||
/// Exports an item to a legacy (.zip based) package.
|
||||
@ -73,6 +65,14 @@ namespace osu.Game.Database
|
||||
|
||||
string filename = NamingUtils.GetNextBestFilename(existingExports, $"{itemFilename}{FileExtension}");
|
||||
|
||||
if (filename.Length > MAX_FILENAME_LENGTH)
|
||||
{
|
||||
string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename);
|
||||
|
||||
filenameWithoutExtension = filenameWithoutExtension.Remove(MAX_FILENAME_LENGTH - FileExtension.Length);
|
||||
filename = $"{filenameWithoutExtension}{FileExtension}";
|
||||
}
|
||||
|
||||
using (var stream = exportStorage.CreateFileSafely(filename))
|
||||
ExportModelTo(item, stream);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user