Move logging and early return into UndeleteForReuse method itself

This commit is contained in:
Dean Herbert 2022-04-13 14:33:28 +09:00
parent 6dbfc26158
commit 56427becbb

View File

@ -351,7 +351,6 @@ namespace osu.Game.Stores
using (var transaction = realm.BeginWrite())
{
if (existing.DeletePending)
UndeleteForReuse(existing);
transaction.Commit();
}
@ -388,12 +387,7 @@ namespace osu.Game.Stores
{
LogForModel(item, @$"Found existing {HumanisedModelName} for {item} (ID {existing.ID}) skipping import.");
if (existing.DeletePending)
{
LogForModel(item, $@"Existing {HumanisedModelName}'s deletion flag has been removed");
UndeleteForReuse(existing);
}
transaction.Commit();
return existing.ToLive(Realm);
@ -539,6 +533,10 @@ namespace osu.Game.Stores
/// <param name="existing">The existing model.</param>
protected virtual void UndeleteForReuse(TModel existing)
{
if (!existing.DeletePending)
return;
LogForModel(existing, $@"Existing {HumanisedModelName}'s deletion flag has been removed to allow for reuse.");
existing.DeletePending = false;
}