Add test for rollback logic correctly dereferencing files

This commit is contained in:
Dean Herbert
2019-06-10 16:45:45 +09:00
parent 02b376d962
commit 5b75060b94
2 changed files with 23 additions and 0 deletions

View File

@ -2,8 +2,11 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
using osu.Framework.Extensions;
using osu.Framework.IO.Stores;
using osu.Framework.Logging;
@ -27,6 +30,13 @@ namespace osu.Game.IO
Store = new StorageBackedResourceStore(Storage);
}
/// <summary>
/// Perform a lookup query on available <see cref="FileInfo"/>s.
/// </summary>
/// <param name="query">The query.</param>
/// <returns>Results from the provided query.</returns>
public IEnumerable<FileInfo> QueryFiles(Expression<Func<FileInfo, bool>> query) => ContextFactory.Get().Set<FileInfo>().AsNoTracking().Where(f => f.ReferenceCount > 0).Where(query);
public FileInfo Add(Stream data, bool reference = true)
{
using (var usage = ContextFactory.GetForWrite())