diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index 2dcd1b137c..e124e38dd9 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -229,6 +229,8 @@ namespace osu.Game.Beatmaps
/// Results from the provided query.
public IQueryable QueryBeatmaps(Expression> query) => beatmaps.Beatmaps.AsNoTracking().Where(query);
+ public override bool IsAvailableLocally(BeatmapSetInfo set) => beatmaps.ConsumableItems.Any(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending && !s.Protected);
+
protected override BeatmapSetInfo CreateModel(ArchiveReader reader)
{
// let's make sure there are actually .osu files to import.
diff --git a/osu.Game/Database/ArchiveDownloadModelManager.cs b/osu.Game/Database/ArchiveDownloadModelManager.cs
index 2fb661ccce..c868b8d1d5 100644
--- a/osu.Game/Database/ArchiveDownloadModelManager.cs
+++ b/osu.Game/Database/ArchiveDownloadModelManager.cs
@@ -18,18 +18,12 @@ namespace osu.Game.Database
///
/// The model type.
/// The associated file join type.
- public abstract class ArchiveDownloadModelManager : ArchiveModelManager
+ public abstract class ArchiveDownloadModelManager : ArchiveModelManager, IDownloadModelManager
where TModel : class, IHasFiles, IHasPrimaryKey, ISoftDelete
where TFileModel : INamedFileInfo, new()
{
- ///
- /// Fired when a download begins.
- ///
public event Action> DownloadBegan;
- ///
- /// Fired when a download is interrupted, either due to user cancellation or failure.
- ///
public event Action> DownloadFailed;
private readonly IAPIProvider api;
@@ -55,12 +49,6 @@ namespace osu.Game.Database
/// The request object.
protected abstract ArchiveDownloadModelRequest CreateDownloadRequest(TModel model, object[] options);
- ///
- /// Downloads a .
- /// This will post notifications tracking progress.
- ///
- /// The to be downloaded.
- /// Whether downloading can happen.
public bool Download(TModel model)
{
if (!canDownload(model)) return false;
@@ -72,13 +60,6 @@ namespace osu.Game.Database
return true;
}
- ///
- /// Downloads a with optional parameters for the download request.
- /// This will post notifications tracking progress.
- ///
- /// The to be downloaded.
- /// Optional parameters to be used for creating the download request.
- /// Whether downloading can happen.
public bool Download(TModel model, params object[] extra)
{
if (!canDownload(model)) return false;
@@ -90,12 +71,7 @@ namespace osu.Game.Database
return true;
}
- ///
- /// Checks whether a given is available in the local store already.
- ///
- /// The whose existence needs to be checked.
- /// Whether the exists locally.
- public bool IsAvailableLocally(TModel model) => modelStore.ConsumableItems.Any(m => m.Equals(model));
+ public virtual bool IsAvailableLocally(TModel model) => modelStore.ConsumableItems.Any(m => m.Equals(model) && !m.DeletePending);
///
/// Gets an existing download request if it exists.
diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs
index 54dbae9ddc..50cb9dac8b 100644
--- a/osu.Game/Database/ArchiveModelManager.cs
+++ b/osu.Game/Database/ArchiveModelManager.cs
@@ -29,7 +29,7 @@ namespace osu.Game.Database
///
/// The model type.
/// The associated file join type.
- public abstract class ArchiveModelManager : ICanAcceptFiles
+ public abstract class ArchiveModelManager : ICanAcceptFiles, IModelManager
where TModel : class, IHasFiles, IHasPrimaryKey, ISoftDelete
where TFileModel : INamedFileInfo, new()
{
diff --git a/osu.Game/Database/IDownloadModelManager.cs b/osu.Game/Database/IDownloadModelManager.cs
new file mode 100644
index 0000000000..3231d855ea
--- /dev/null
+++ b/osu.Game/Database/IDownloadModelManager.cs
@@ -0,0 +1,47 @@
+using osu.Game.Online.API;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace osu.Game.Database
+{
+ public interface IDownloadModelManager : IModelManager
+ where TModel : class
+ {
+ ///
+ /// Fired when a download begins.
+ ///
+ event Action> DownloadBegan;
+
+ ///
+ /// Fired when a download is interrupted, either due to user cancellation or failure.
+ ///
+ event Action> DownloadFailed;
+
+ bool IsAvailableLocally(TModel model);
+
+ ///
+ /// Downloads a .
+ /// This will post notifications tracking progress.
+ ///
+ /// The to be downloaded.
+ /// Whether downloading can happen.
+ bool Download(TModel model);
+
+ ///
+ /// Downloads a with optional parameters for the download request.
+ /// This will post notifications tracking progress.
+ ///
+ /// The to be downloaded.
+ /// Optional parameters to be used for creating the download request.
+ /// Whether downloading can happen.
+ bool Download(TModel model, params object[] extra);
+
+ ///
+ /// Checks whether a given is available in the local store already.
+ ///
+ /// The whose existence needs to be checked.
+ /// Whether the exists locally.
+ ArchiveDownloadModelRequest GetExistingDownload(TModel model);
+ }
+}
diff --git a/osu.Game/Database/IModelManager.cs b/osu.Game/Database/IModelManager.cs
new file mode 100644
index 0000000000..6a0b2bde44
--- /dev/null
+++ b/osu.Game/Database/IModelManager.cs
@@ -0,0 +1,20 @@
+
+using System;
+
+namespace osu.Game.Database
+{
+ public interface IModelManager
+ {
+ ///
+ /// Fired when a new becomes available in the database.
+ /// This is not guaranteed to run on the update thread.
+ ///
+ event Action ItemAdded;
+
+ ///
+ /// Fired when a is removed from the database.
+ /// This is not guaranteed to run on the update thread.
+ ///
+ event Action ItemRemoved;
+ }
+}