mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:52:57 +08:00
Allow retrieving count of available stable imports
This commit is contained in:
parent
4412fec41a
commit
6448c97929
@ -111,6 +111,18 @@ namespace osu.Game.Collections
|
|||||||
|
|
||||||
public Action<Notification> PostNotification { protected get; set; }
|
public Action<Notification> PostNotification { protected get; set; }
|
||||||
|
|
||||||
|
public Task<int> GetAvailableCount(StableStorage stableStorage)
|
||||||
|
{
|
||||||
|
if (!stableStorage.Exists(database_name))
|
||||||
|
return Task.FromResult(0);
|
||||||
|
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
using (var stream = stableStorage.GetStream(database_name))
|
||||||
|
return readCollections(stream).Count;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
|
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -49,6 +49,29 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
public bool SupportsImportFromStable => RuntimeInfo.IsDesktop;
|
public bool SupportsImportFromStable => RuntimeInfo.IsDesktop;
|
||||||
|
|
||||||
|
public async Task<int> GetImportCount(StableContent content)
|
||||||
|
{
|
||||||
|
var stableStorage = await getStableStorage().ConfigureAwait(false);
|
||||||
|
|
||||||
|
switch (content)
|
||||||
|
{
|
||||||
|
case StableContent.Beatmaps:
|
||||||
|
return await new LegacyBeatmapImporter(beatmaps).GetAvailableCount(stableStorage);
|
||||||
|
|
||||||
|
case StableContent.Skins:
|
||||||
|
return await new LegacySkinImporter(skins).GetAvailableCount(stableStorage);
|
||||||
|
|
||||||
|
case StableContent.Collections:
|
||||||
|
return await collections.GetAvailableCount(stableStorage);
|
||||||
|
|
||||||
|
case StableContent.Scores:
|
||||||
|
return await new LegacyScoreImporter(scores).GetAvailableCount(stableStorage);
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Only one {nameof(StableContent)} flag should be specified.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task ImportFromStableAsync(StableContent content)
|
public async Task ImportFromStableAsync(StableContent content)
|
||||||
{
|
{
|
||||||
var stableStorage = await getStableStorage().ConfigureAwait(false);
|
var stableStorage = await getStableStorage().ConfigureAwait(false);
|
||||||
|
@ -34,6 +34,8 @@ namespace osu.Game.Database
|
|||||||
Importer = importer;
|
Importer = importer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<int> GetAvailableCount(StableStorage stableStorage) => Task.Run(() => GetStableImportPaths(stableStorage).Count());
|
||||||
|
|
||||||
public Task ImportFromStableAsync(StableStorage stableStorage)
|
public Task ImportFromStableAsync(StableStorage stableStorage)
|
||||||
{
|
{
|
||||||
var storage = PrepareStableStorage(stableStorage);
|
var storage = PrepareStableStorage(stableStorage);
|
||||||
|
Loading…
Reference in New Issue
Block a user