mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:52:57 +08:00
Overwrite existing files if AddFile
is called with an existing filename
This commit is contained in:
parent
ec700e9142
commit
ae3038ead4
@ -25,7 +25,7 @@ namespace osu.Game.Database
|
||||
void DeleteFile(TModel model, TFileModel file);
|
||||
|
||||
/// <summary>
|
||||
/// Add a new file.
|
||||
/// Add a new file. If the file already exists, it is overwritten.
|
||||
/// </summary>
|
||||
/// <param name="model">The item to operate on.</param>
|
||||
/// <param name="contents">The new file contents.</param>
|
||||
|
@ -74,10 +74,18 @@ namespace osu.Game.Stores
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a file from within an ongoing realm transaction.
|
||||
/// Add a file from within an ongoing realm transaction. If the file already exists, it is overwritten.
|
||||
/// </summary>
|
||||
protected void AddFile(TModel item, Stream stream, string filename, Realm realm)
|
||||
{
|
||||
var existing = item.Files.FirstOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
ReplaceFile(item, existing, stream, realm);
|
||||
return;
|
||||
}
|
||||
|
||||
var file = realmFileStore.Add(stream, realm);
|
||||
var namedUsage = new RealmNamedFileUsage(file, filename);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user