mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 09:20:02 +09:00
Add ImportAsUpdate
method to IModelImporter
to avoid otehr changes
This commit is contained in:
@ -44,6 +44,8 @@ namespace osu.Game.Database
|
||||
|
||||
public bool Download(T model, bool minimiseDownloadSize = false) => Download(model, minimiseDownloadSize, null);
|
||||
|
||||
public void DownloadAsUpdate(TModel originalModel) => Download(originalModel, false, originalModel);
|
||||
|
||||
protected bool Download(T model, bool minimiseDownloadSize, TModel? originalModel)
|
||||
{
|
||||
if (!canDownload(model)) return false;
|
||||
@ -66,7 +68,7 @@ namespace osu.Game.Database
|
||||
Task.Factory.StartNew(async () =>
|
||||
{
|
||||
// This gets scheduled back to the update thread, but we want the import to run in the background.
|
||||
var imported = await Import(notification, filename, originalModel).ConfigureAwait(false);
|
||||
var imported = await importer.Import(notification, new ImportTask(filename)).ConfigureAwait(false);
|
||||
|
||||
// for now a failed import will be marked as a failed download for simplicity.
|
||||
if (!imported.Any())
|
||||
@ -105,18 +107,6 @@ namespace osu.Game.Database
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run the post-download import for the model.
|
||||
/// </summary>
|
||||
/// <param name="notification">The notification to update.</param>
|
||||
/// <param name="filename">The path of the temporary downloaded file.</param>
|
||||
/// <param name="originalModel">An optional model for update scenarios, to be used as a reference.</param>
|
||||
/// <returns>The imported model.</returns>
|
||||
protected virtual Task<IEnumerable<Live<TModel>>> Import(ProgressNotification notification, string filename, TModel? originalModel)
|
||||
{
|
||||
return importer.Import(notification, new ImportTask(filename));
|
||||
}
|
||||
|
||||
public abstract ArchiveDownloadRequest<T>? GetExistingDownload(T model);
|
||||
|
||||
private bool canDownload(T model) => GetExistingDownload(model) == null && api != null;
|
||||
|
Reference in New Issue
Block a user