Remove subscription logic for the time being

This commit is contained in:
Dean Herbert 2021-12-02 12:20:07 +09:00
parent 1cf1543866
commit 4f826589e5

View File

@ -1,14 +1,10 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using osu.Framework.Development;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Game.Extensions; using osu.Game.Extensions;
using Realms;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -16,38 +12,12 @@ namespace osu.Game.Skinning
{ {
private readonly Dictionary<string, string> fileToStoragePathMapping = new Dictionary<string, string>(); private readonly Dictionary<string, string> fileToStoragePathMapping = new Dictionary<string, string>();
private readonly IDisposable subscription;
public LegacyDatabasedSkinResourceStore(SkinInfo source, IResourceStore<byte[]> underlyingStore) public LegacyDatabasedSkinResourceStore(SkinInfo source, IResourceStore<byte[]> underlyingStore)
: base(underlyingStore) : base(underlyingStore)
{ {
// Subscribing to non-managed instances doesn't work.
// In this usage, the skin may be non-managed in tests.
if (source.IsManaged)
{
// Subscriptions can only work on the main thread.
Debug.Assert(ThreadSafety.IsUpdateThread);
subscription = source.Files
.AsRealmCollection().SubscribeForNotifications((sender, changes, error) =>
{
if (changes == null)
return;
// If a large number of changes are made on skin files, this may be better suited to being cleared here
// and reinitialised on next usage.
initialiseFileCache(source);
});
}
initialiseFileCache(source); initialiseFileCache(source);
} }
~LegacyDatabasedSkinResourceStore()
{
Dispose(false);
}
private void initialiseFileCache(SkinInfo source) private void initialiseFileCache(SkinInfo source)
{ {
fileToStoragePathMapping.Clear(); fileToStoragePathMapping.Clear();
@ -65,13 +35,6 @@ namespace osu.Game.Skinning
} }
} }
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
subscription?.Dispose();
}
private string getPathForFile(string filename) => private string getPathForFile(string filename) =>
fileToStoragePathMapping.TryGetValue(filename.ToLower(), out string path) ? path : null; fileToStoragePathMapping.TryGetValue(filename.ToLower(), out string path) ? path : null;