Skip to content

Commit

Permalink
fix dependency on absolute path rather than filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Flutterish committed Dec 28, 2021
1 parent f96e0c7 commit 31fd003
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions osu.Game.Rulesets.RurusettoAddon/RulesetDownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public RulesetDownloadManager ( RurusettoAPI API, Storage storage ) {
InstalledRulesets = Array.Empty<RulesetInfo>();
UnimportedRulesets = Array.Empty<(string, string)>();

InstalledRulesetPaths = new Dictionary<RulesetInfo, string>();
InstalledRulesetFilenames = new Dictionary<RulesetInfo, string>();

PerformPreCleanup();
}

Expand All @@ -30,12 +33,16 @@ public RulesetDownloadManager ( RurusettoAPI API, Storage storage, IRulesetStore

InstalledRulesets = store.AvailableRulesets.Cast<RulesetInfo>();
Dictionary<RulesetInfo, string> filenames = new();
Dictionary<RulesetInfo, string> paths = new();
foreach ( var i in InstalledRulesets ) {
if ( Path.GetFileName( i.CreateInstance()?.GetType().Assembly.Location ) is string filename ) {
var loc = i.CreateInstance()?.GetType().Assembly.Location;
if ( Path.GetFileName( loc ) is string filename ) {
filenames.Add( i, filename );
paths.Add( i, loc );
}
}
InstalledRulesetPaths = filenames;
InstalledRulesetFilenames = filenames;
InstalledRulesetPaths = paths;

List<(string filename, string shortname)> unimportedRulesets = new();
foreach ( var i in storage.GetFiles( "./rulesets", "*.dll" ) ) {
Expand All @@ -51,6 +58,7 @@ public RulesetDownloadManager ( RurusettoAPI API, Storage storage, IRulesetStore
}

public IDictionary<RulesetInfo, string> InstalledRulesetPaths { get; private set; }
public IDictionary<RulesetInfo, string> InstalledRulesetFilenames { get; private set; }
public IEnumerable<RulesetInfo> InstalledRulesets { get; private set; }
public IEnumerable<(string filename, string shortname)> UnimportedRulesets { get; private set; }

Expand All @@ -76,7 +84,7 @@ public void BindWith ( string shortName, IBindable<DownloadState> bindable ) {

public RulesetInfo GetLocalRuleset ( string shortName, string name, string filename ) {
if ( !rulesets.TryGetValue( shortName, out var ruleset ) ) {
ruleset = InstalledRulesetPaths.FirstOrDefault( x =>
ruleset = InstalledRulesetFilenames.FirstOrDefault( x =>
x.Value == filename
).Key;

Expand Down Expand Up @@ -193,7 +201,7 @@ public void RemoveRuleset ( string shortName ) {
}

var unimported = UnimportedRulesets.Where( x => x.shortname == shortName );
var installed = InstalledRulesetPaths.Where( x => x.Key.ShortName == shortName );
var installed = InstalledRulesetFilenames.Where( x => x.Key.ShortName == shortName );
string location;
if ( unimported.Any() ) {
location = unimported.First().filename;
Expand Down

0 comments on commit 31fd003

Please sign in to comment.