Update ArchiveModelManager.cs

This commit is contained in:
Paul Teng
2018-09-20 20:01:04 -04:00
committed by GitHub
parent 7efaaceba5
commit 52877eca83

View File

@ -286,9 +286,10 @@ namespace osu.Game.Database
using (ContextFactory.GetForWrite())
{
// re-fetch the model on the import context.
var foundModel = queryModel().Include(s => s.Files).ThenInclude(f => f.FileInfo).First(s => s.ID == item.ID);
var foundModel = queryModel().Include(s => s.Files).ThenInclude(f => f.FileInfo).FirstOrDefault(s => s.ID == item.ID);
if (foundModel.DeletePending) return;
// Test for null since FirstOrDefault will return null if nothing is found
if (foundModel == null || foundModel.DeletePending) return;
if (ModelStore.Delete(foundModel))
Files.Dereference(foundModel.Files.Select(f => f.FileInfo).ToArray());