mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Workaround InvalidOperation exceptions
This commit is contained in:
@ -462,6 +462,10 @@ namespace osu.Game.Database
|
||||
// Dereference the existing file info, since the file model will be removed.
|
||||
if (file.FileInfo != null)
|
||||
{
|
||||
// Workaround System.InvalidOperationException
|
||||
// The instance of entity type 'FileInfo' cannot be tracked because another instance with the same key value for {'ID'} is already being tracked.
|
||||
file.FileInfo = usage.Context.FileInfo.Find(file.FileInfoID);
|
||||
|
||||
Files.Dereference(file.FileInfo);
|
||||
|
||||
// This shouldn't be required, but here for safety in case the provided TModel is not being change tracked
|
||||
@ -635,10 +639,12 @@ namespace osu.Game.Database
|
||||
{
|
||||
using (Stream s = reader.GetStream(file))
|
||||
{
|
||||
var fileInfo = files.Add(s);
|
||||
fileInfos.Add(new TFileModel
|
||||
{
|
||||
Filename = file.Substring(prefix.Length).ToStandardisedPath(),
|
||||
FileInfo = files.Add(s)
|
||||
FileInfo = fileInfo,
|
||||
FileInfoID = fileInfo.ID
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user