Add boolean return value

This commit is contained in:
Paul Teng 2018-09-20 23:21:27 -04:00
parent 654345f380
commit eaf7697b85

View File

@ -281,7 +281,8 @@ namespace osu.Game.Database
/// Is a no-op for already deleted items.
/// </summary>
/// <param name="item">The item to delete.</param>
public void Delete(TModel item)
/// <returns>false if no operation was performed</returns>
public bool Delete(TModel item)
{
using (ContextFactory.GetForWrite())
{
@ -289,10 +290,11 @@ namespace osu.Game.Database
var foundModel = queryModel().Include(s => s.Files).ThenInclude(f => f.FileInfo).FirstOrDefault(s => s.ID == item.ID);
// Test for null since FirstOrDefault will return null if nothing is found
if (foundModel == null || foundModel.DeletePending) return;
if (foundModel == null || foundModel.DeletePending) return false;
if (ModelStore.Delete(foundModel))
Files.Dereference(foundModel.Files.Select(f => f.FileInfo).ToArray());
return true;
}
}