mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Remove unnecessary branching around EF logic
This commit is contained in:
@ -510,8 +510,6 @@ namespace osu.Game.Database
|
||||
/// <param name="model">The item to operate on.</param>
|
||||
/// <param name="file">The existing file to be deleted.</param>
|
||||
public void DeleteFile(TModel model, TFileModel file)
|
||||
{
|
||||
if (model.ID > 0)
|
||||
{
|
||||
using (var usage = ContextFactory.GetForWrite())
|
||||
{
|
||||
@ -531,12 +529,6 @@ namespace osu.Game.Database
|
||||
model.Files.Remove(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Files.Dereference(file.FileInfo);
|
||||
model.Files.Remove(file);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a new file.
|
||||
@ -545,8 +537,6 @@ namespace osu.Game.Database
|
||||
/// <param name="contents">The new file contents.</param>
|
||||
/// <param name="filename">The filename for the new file.</param>
|
||||
public void AddFile(TModel model, Stream contents, string filename)
|
||||
{
|
||||
if (model.ID > 0)
|
||||
{
|
||||
using (ContextFactory.GetForWrite())
|
||||
{
|
||||
@ -555,21 +545,11 @@ namespace osu.Game.Database
|
||||
Filename = filename,
|
||||
FileInfo = Files.Add(contents)
|
||||
});
|
||||
}
|
||||
|
||||
if (model.ID > 0)
|
||||
Update(model);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This function may be called during the import process.
|
||||
// Should not exist like this once we have switched to realm.
|
||||
model.Files.Add(new TFileModel
|
||||
{
|
||||
Filename = filename,
|
||||
FileInfo = Files.Add(contents)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform an update of the specified item.
|
||||
|
Reference in New Issue
Block a user