Clean up stable lookup and mutate logic

This commit is contained in:
Dean Herbert 2019-07-05 13:59:31 +09:00
parent 8346c50ce1
commit ba8df3ba92
3 changed files with 5 additions and 8 deletions

View File

@ -486,7 +486,7 @@ namespace osu.Game.Database
/// <summary> /// <summary>
/// Set a storage with access to an osu-stable install for import purposes. /// Set a storage with access to an osu-stable install for import purposes.
/// </summary> /// </summary>
public Func<Storage> GetStableStorage { protected get; set; } public Func<Storage> GetStableStorage { private get; set; }
/// <summary> /// <summary>
/// Denotes whether an osu-stable installation is present to perform automated imports from. /// Denotes whether an osu-stable installation is present to perform automated imports from.
@ -501,7 +501,7 @@ namespace osu.Game.Database
/// <summary> /// <summary>
/// Selects paths to import from. /// Selects paths to import from.
/// </summary> /// </summary>
protected abstract IEnumerable<string> GetStableImportPaths(); protected virtual IEnumerable<string> GetStableImportPaths(Storage stableStoage) => stableStoage.GetDirectories(ImportFromStablePath);
/// <summary> /// <summary>
/// Whether this specified path should be removed after successful import. /// Whether this specified path should be removed after successful import.
@ -530,7 +530,7 @@ namespace osu.Game.Database
return Task.CompletedTask; return Task.CompletedTask;
} }
return Task.Run(async () => await Import(GetStableImportPaths().Select(f => stable.GetFullPath(f)).ToArray())); return Task.Run(async () => await Import(GetStableImportPaths(GetStableStorage()).Select(f => stable.GetFullPath(f)).ToArray()));
} }
#endregion #endregion

View File

@ -56,9 +56,8 @@ namespace osu.Game.Scoring
} }
} }
protected override IEnumerable<string> GetStableImportPaths() protected override IEnumerable<string> GetStableImportPaths(Storage stableStorage)
=> GetStableStorage().GetFiles(ImportFromStablePath) => stableStorage.GetFiles(ImportFromStablePath).Where(p => HandledExtensions.Any(ext => Path.GetExtension(p)?.Equals(ext, StringComparison.InvariantCultureIgnoreCase) ?? false));
.Where(p => HandledExtensions.Any(ext => Path.GetExtension(p)?.Equals(ext, StringComparison.InvariantCultureIgnoreCase) ?? false));
public Score GetScore(ScoreInfo score) => new LegacyDatabasedScore(score, rulesets, beatmaps(), Files.Store); public Score GetScore(ScoreInfo score) => new LegacyDatabasedScore(score, rulesets, beatmaps(), Files.Store);

View File

@ -55,8 +55,6 @@ namespace osu.Game.Skinning
}; };
} }
protected override IEnumerable<string> GetStableImportPaths() => GetStableStorage().GetDirectories(ImportFromStablePath);
protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osk"; protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osk";
/// <summary> /// <summary>