diff --git a/osu.Game/Database/IModelFileManager.cs b/osu.Game/Database/IModelFileManager.cs
index 4bc1e2d29b..390be4a69d 100644
--- a/osu.Game/Database/IModelFileManager.cs
+++ b/osu.Game/Database/IModelFileManager.cs
@@ -25,7 +25,7 @@ namespace osu.Game.Database
void DeleteFile(TModel model, TFileModel file);
///
- /// Add a new file.
+ /// Add a new file. If the file already exists, it is overwritten.
///
/// The item to operate on.
/// The new file contents.
diff --git a/osu.Game/Stores/RealmArchiveModelManager.cs b/osu.Game/Stores/RealmArchiveModelManager.cs
index a916e2b53a..4efcdd096c 100644
--- a/osu.Game/Stores/RealmArchiveModelManager.cs
+++ b/osu.Game/Stores/RealmArchiveModelManager.cs
@@ -74,10 +74,18 @@ namespace osu.Game.Stores
}
///
- /// 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.
///
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);