@@ -747,6 +747,11 @@ protected virtual ParsedSearchResult CleanSearchResult(ISearchParserResult parse
747747 /// <returns>IEnumerable<IModInstallationResult>.</returns>
748748 protected virtual IEnumerable < IModInstallationResult > GetAllModDescriptors ( string path , ModSource modSource , ModDescriptorType modDescriptorType )
749749 {
750+ bool IsSubPath ( string path , string potentialParent )
751+ {
752+ return path . StartsWith ( potentialParent . TrimEnd ( '\\ ' ) + "\\ " , StringComparison . OrdinalIgnoreCase ) ;
753+ }
754+
750755 // Json metadata doesn't support zips to ignore them
751756 var files = Directory . Exists ( path ) && modDescriptorType == ModDescriptorType . DescriptorMod
752757 ? Directory . EnumerateFiles ( path , $ "*{ Shared . Constants . ZipExtension } ") . Union ( Directory . EnumerateFiles ( path , $ "*{ Shared . Constants . BinExtension } ") )
@@ -756,21 +761,14 @@ protected virtual IEnumerable<IModInstallationResult> GetAllModDescriptors(strin
756761
757762 static void setDescriptorPath ( IMod mod , string desiredPath , string localPath )
758763 {
759- if ( desiredPath . Equals ( localPath , StringComparison . OrdinalIgnoreCase ) )
764+ if ( desiredPath . Equals ( localPath , StringComparison . OrdinalIgnoreCase ) || mod . RemoteId . GetValueOrDefault ( ) > 0 )
760765 {
761766 mod . DescriptorFile = desiredPath ;
762767 }
763768 else
764769 {
765- if ( mod . RemoteId . GetValueOrDefault ( ) > 0 )
766- {
767- mod . DescriptorFile = desiredPath ;
768- }
769- else
770- {
771- mod . Source = ModSource . Local ;
772- mod . DescriptorFile = localPath ;
773- }
770+ mod . Source = ModSource . Local ;
771+ mod . DescriptorFile = localPath ;
774772 }
775773 }
776774
@@ -836,6 +834,7 @@ void parseModFiles(string path, ModSource source, bool isDirectory, string modNa
836834 ? $ "{ Shared . Constants . ModDirectory } /{ cleanedPath . Split ( Path . DirectorySeparatorChar , StringSplitOptions . RemoveEmptyEntries ) . LastOrDefault ( ) } { Shared . Constants . ModExtension } "
837835 : $ "{ Shared . Constants . JsonModDirectory } /{ cleanedPath . Split ( Path . DirectorySeparatorChar , StringSplitOptions . RemoveEmptyEntries ) . LastOrDefault ( ) } { Shared . Constants . JsonExtension } ";
838836
837+ // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
839838 switch ( mod . Source )
840839 {
841840 case ModSource . Local :
@@ -924,7 +923,7 @@ void parseModFiles(string path, ModSource source, bool isDirectory, string modNa
924923 }
925924
926925 var subdirectories = Directory . GetDirectories ( directory ) ;
927- if ( subdirectories . Length != 0 && modSourceOverride != ModSource . Steam )
926+ if ( subdirectories . Length != 0 )
928927 {
929928 foreach ( var subdirectory in subdirectories )
930929 {
@@ -938,7 +937,11 @@ void parseModFiles(string path, ModSource source, bool isDirectory, string modNa
938937 } ) ;
939938 }
940939
941- return [ .. mods ] ;
940+ var filtered = mods
941+ . Where ( x => ! mods . Any ( y => x != y && IsSubPath ( x . Path , y . Path ) ) )
942+ . ToList ( ) ;
943+
944+ return [ .. filtered ] ;
942945 }
943946
944947 /// <summary>
0 commit comments