mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 05:22:54 +08:00
Report any error during import to the write context to allow for rollback
This commit is contained in:
parent
cc081cad5a
commit
3d3026a80c
@ -181,21 +181,29 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
using (var write = ContextFactory.GetForWrite()) // used to share a context for full import. keep in mind this will block all writes.
|
using (var write = ContextFactory.GetForWrite()) // used to share a context for full import. keep in mind this will block all writes.
|
||||||
{
|
{
|
||||||
if (!write.IsTransactionLeader) throw new InvalidOperationException($"Ensure there is no parent transaction so errors can correctly be handled by {this}");
|
try
|
||||||
|
{
|
||||||
|
if (!write.IsTransactionLeader) throw new InvalidOperationException($"Ensure there is no parent transaction so errors can correctly be handled by {this}");
|
||||||
|
|
||||||
// create a new model (don't yet add to database)
|
// create a new model (don't yet add to database)
|
||||||
item = CreateModel(archive);
|
item = CreateModel(archive);
|
||||||
|
|
||||||
var existing = CheckForExisting(item);
|
var existing = CheckForExisting(item);
|
||||||
|
|
||||||
if (existing != null) return existing;
|
if (existing != null) return existing;
|
||||||
|
|
||||||
item.Files = createFileInfos(archive, Files);
|
item.Files = createFileInfos(archive, Files);
|
||||||
|
|
||||||
Populate(item, archive);
|
Populate(item, archive);
|
||||||
|
|
||||||
// import to store
|
// import to store
|
||||||
ModelStore.Add(item);
|
ModelStore.Add(item);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
write.Errors.Add(e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
Loading…
Reference in New Issue
Block a user