Fix event flushing sticking on early return

This commit is contained in:
Dean Herbert 2018-05-29 19:43:52 +09:00
parent 4a18951cce
commit 31ab6f2408
1 changed files with 6 additions and 3 deletions

View File

@ -174,7 +174,7 @@ public void Import(params string[] paths)
/// <param name="archive">The archive to be imported.</param>
public TModel Import(ArchiveReader archive)
{
TModel item;
TModel item = null;
delayEvents();
try
@ -211,9 +211,12 @@ public TModel Import(ArchiveReader archive)
Logger.Error(e, $"Import of {archive.Name} failed and has been rolled back.", LoggingTarget.Database);
item = null;
}
finally
{
// we only want to flush events after we've confirmed the write context didn't have any errors.
flushEvents(item != null);
}
// we only want to flush events after we've confirmed the write context didn't have any errors.
flushEvents(item != null);
return item;
}