mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Fix model file infos not being removed
This commit is contained in:
@ -34,7 +34,7 @@ namespace osu.Game.Database
|
|||||||
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
||||||
public abstract class ArchiveModelManager<TModel, TFileModel> : ICanAcceptFiles, IModelManager<TModel>
|
public abstract class ArchiveModelManager<TModel, TFileModel> : ICanAcceptFiles, IModelManager<TModel>
|
||||||
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
||||||
where TFileModel : INamedFileInfo, new()
|
where TFileModel : class, INamedFileInfo, new()
|
||||||
{
|
{
|
||||||
private const int import_queue_request_concurrency = 1;
|
private const int import_queue_request_concurrency = 1;
|
||||||
|
|
||||||
@ -366,8 +366,15 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
public void UpdateFile(TModel model, TFileModel file, Stream contents)
|
public void UpdateFile(TModel model, TFileModel file, Stream contents)
|
||||||
{
|
{
|
||||||
using (ContextFactory.GetForWrite())
|
using (var usage = ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
|
// Dereference the existing file info, since the file model will be removed.
|
||||||
|
Files.Dereference(file.FileInfo);
|
||||||
|
|
||||||
|
// Remove the file model.
|
||||||
|
usage.Context.Set<TFileModel>().Remove(file);
|
||||||
|
|
||||||
|
// Add the new file info and containing file model.
|
||||||
model.Files.Remove(file);
|
model.Files.Remove(file);
|
||||||
model.Files.Add(new TFileModel
|
model.Files.Add(new TFileModel
|
||||||
{
|
{
|
||||||
@ -375,8 +382,6 @@ namespace osu.Game.Database
|
|||||||
FileInfo = Files.Add(contents)
|
FileInfo = Files.Add(contents)
|
||||||
});
|
});
|
||||||
|
|
||||||
Files.Dereference(file.FileInfo);
|
|
||||||
|
|
||||||
Update(model);
|
Update(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Database
|
|||||||
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
||||||
public abstract class DownloadableArchiveModelManager<TModel, TFileModel> : ArchiveModelManager<TModel, TFileModel>, IModelDownloader<TModel>
|
public abstract class DownloadableArchiveModelManager<TModel, TFileModel> : ArchiveModelManager<TModel, TFileModel>, IModelDownloader<TModel>
|
||||||
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete, IEquatable<TModel>
|
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete, IEquatable<TModel>
|
||||||
where TFileModel : INamedFileInfo, new()
|
where TFileModel : class, INamedFileInfo, new()
|
||||||
{
|
{
|
||||||
public event Action<ArchiveDownloadRequest<TModel>> DownloadBegan;
|
public event Action<ArchiveDownloadRequest<TModel>> DownloadBegan;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user