mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 04:02:59 +08:00
Merge pull request #15856 from peppy/simplify-replace-file
Remove the ability to specify a filename in `ReplaceFile`
This commit is contained in:
commit
823552a5e8
@ -288,9 +288,9 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
#region Implementation of IModelFileManager<in BeatmapSetInfo,in BeatmapSetFileInfo>
|
#region Implementation of IModelFileManager<in BeatmapSetInfo,in BeatmapSetFileInfo>
|
||||||
|
|
||||||
public void ReplaceFile(BeatmapSetInfo model, BeatmapSetFileInfo file, Stream contents, string filename = null)
|
public void ReplaceFile(BeatmapSetInfo model, BeatmapSetFileInfo file, Stream contents)
|
||||||
{
|
{
|
||||||
beatmapModelManager.ReplaceFile(model, file, contents, filename);
|
beatmapModelManager.ReplaceFile(model, file, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteFile(BeatmapSetInfo model, BeatmapSetFileInfo file)
|
public void DeleteFile(BeatmapSetInfo model, BeatmapSetFileInfo file)
|
||||||
|
@ -453,13 +453,12 @@ namespace osu.Game.Database
|
|||||||
/// <param name="model">The item to operate on.</param>
|
/// <param name="model">The item to operate on.</param>
|
||||||
/// <param name="file">The existing file to be replaced.</param>
|
/// <param name="file">The existing file to be replaced.</param>
|
||||||
/// <param name="contents">The new file contents.</param>
|
/// <param name="contents">The new file contents.</param>
|
||||||
/// <param name="filename">An optional filename for the new file. Will use the previous filename if not specified.</param>
|
public void ReplaceFile(TModel model, TFileModel file, Stream contents)
|
||||||
public void ReplaceFile(TModel model, TFileModel file, Stream contents, string filename = null)
|
|
||||||
{
|
{
|
||||||
using (ContextFactory.GetForWrite())
|
using (ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
DeleteFile(model, file);
|
DeleteFile(model, file);
|
||||||
AddFile(model, contents, filename ?? file.Filename);
|
AddFile(model, contents, file.Filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="model">The item to operate on.</param>
|
/// <param name="model">The item to operate on.</param>
|
||||||
/// <param name="file">The existing file to be replaced.</param>
|
/// <param name="file">The existing file to be replaced.</param>
|
||||||
/// <param name="contents">The new file contents.</param>
|
/// <param name="contents">The new file contents.</param>
|
||||||
/// <param name="filename">An optional filename for the new file. Will use the previous filename if not specified.</param>
|
void ReplaceFile(TModel model, TFileModel file, Stream contents);
|
||||||
void ReplaceFile(TModel model, TFileModel file, Stream contents, string filename = null);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete an existing file.
|
/// Delete an existing file.
|
||||||
|
@ -78,8 +78,8 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
using (var stream = info.OpenRead())
|
using (var stream = info.OpenRead())
|
||||||
{
|
{
|
||||||
if (oldFile != null)
|
if (oldFile != null)
|
||||||
beatmaps.ReplaceFile(set, oldFile, stream, info.Name);
|
beatmaps.DeleteFile(set, oldFile);
|
||||||
else
|
|
||||||
beatmaps.AddFile(set, stream, info.Name);
|
beatmaps.AddFile(set, stream, info.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,8 +105,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
using (var stream = info.OpenRead())
|
using (var stream = info.OpenRead())
|
||||||
{
|
{
|
||||||
if (oldFile != null)
|
if (oldFile != null)
|
||||||
beatmaps.ReplaceFile(set, oldFile, stream, info.Name);
|
beatmaps.DeleteFile(set, oldFile);
|
||||||
else
|
|
||||||
beatmaps.AddFile(set, stream, info.Name);
|
beatmaps.AddFile(set, stream, info.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ namespace osu.Game.Skinning
|
|||||||
var oldFile = skin.SkinInfo.Files.FirstOrDefault(f => f.Filename == filename);
|
var oldFile = skin.SkinInfo.Files.FirstOrDefault(f => f.Filename == filename);
|
||||||
|
|
||||||
if (oldFile != null)
|
if (oldFile != null)
|
||||||
skinModelManager.ReplaceFile(skin.SkinInfo, oldFile, streamContent, oldFile.Filename);
|
skinModelManager.ReplaceFile(skin.SkinInfo, oldFile, streamContent);
|
||||||
else
|
else
|
||||||
skinModelManager.AddFile(skin.SkinInfo, streamContent, filename);
|
skinModelManager.AddFile(skin.SkinInfo, streamContent, filename);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user