diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs
index 915d980d24..49d7edd56c 100644
--- a/osu.Game/Database/ArchiveModelManager.cs
+++ b/osu.Game/Database/ArchiveModelManager.cs
@@ -397,15 +397,24 @@ namespace osu.Game.Database
}
}
+ ///
+ /// Update an existing file, or create a new entry if not already part of the 's files.
+ ///
+ /// The item to operate on.
+ /// The file model to be updated or added.
+ /// The new file contents.
public void UpdateFile(TModel model, TFileModel file, Stream contents)
{
using (var usage = ContextFactory.GetForWrite())
{
// Dereference the existing file info, since the file model will be removed.
- Files.Dereference(file.FileInfo);
+ if (file.FileInfo != null)
+ {
+ Files.Dereference(file.FileInfo);
- // Remove the file model.
- usage.Context.Set().Remove(file);
+ // Remove the file model.
+ usage.Context.Set().Remove(file);
+ }
// Add the new file info and containing file model.
model.Files.Remove(file);