diff --git a/osu.Game/Database/ModelManager.cs b/osu.Game/Database/ModelManager.cs index 5ecf1e0080..7a5fb5efbf 100644 --- a/osu.Game/Database/ModelManager.cs +++ b/osu.Game/Database/ModelManager.cs @@ -81,19 +81,16 @@ namespace osu.Game.Database } /// - /// Add a file from within an ongoing realm transaction. If the file already exists, it is overwritten so long as is true. + /// Add a file from within an ongoing realm transaction. If the file already exists, it is overwritten. /// - public void AddFile(TModel item, Stream contents, string filename, Realm realm, bool overwrite = true) + public void AddFile(TModel item, Stream contents, string filename, Realm realm) { - if (overwrite) - { - var existing = item.GetFile(filename); + var existing = item.GetFile(filename); - if (existing != null) - { - ReplaceFile(existing, contents, realm); - return; - } + if (existing != null) + { + ReplaceFile(existing, contents, realm); + return; } var file = realmFileStore.Add(contents, realm); diff --git a/osu.Game/Skinning/SkinImporter.cs b/osu.Game/Skinning/SkinImporter.cs index aba14efb2f..8147287eec 100644 --- a/osu.Game/Skinning/SkinImporter.cs +++ b/osu.Game/Skinning/SkinImporter.cs @@ -59,7 +59,6 @@ namespace osu.Game.Skinning skinInfoLive.PerformWrite(skinInfo => { - // Not sure if this deletes the files from the storage or just the database. skinInfo.Files.Clear(); string[] filesInMountedDirectory = Directory.EnumerateFiles(task.Path, "*.*", SearchOption.AllDirectories).Select(f => Path.GetRelativePath(task.Path, f)).ToArray(); @@ -68,7 +67,9 @@ namespace osu.Game.Skinning { using var stream = File.OpenRead(Path.Combine(task.Path, file)); - modelManager.AddFile(original, stream, file, Realm.Realm, false); + // The GetFile call in this method is *really* expensive, and we are certain that the file does not exist in the skin yet. + // Consider adding a method to add a file without checking if it already exists. Or add the file directly to the skin. + modelManager.AddFile(original, stream, file); } });