Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings_Engine: Default to not loading all directories when loading settings #3184

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Settings_Engine/Compute/LoadSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public static partial class Compute
[Input("settingsFolder", "Optional input to determine where to load settings from. Defaults to %ProgramData%/BHoM/Settings if no folder is provided.")]
[Input("fileFilter", "Optional input to filter which types of files to load settings from. Defaults to all JSON (.json) files within the provided folder.")]
[Input("forceLoad", "Optional input to determine whether settings should be loaded even if they have already been loaded. If true, and settings have previously been loaded, then settings will be reloaded from the provided folder path.")]
public static void LoadSettings(string settingsFolder = null, string fileFilter = "*.json", bool forceLoad = false)
[Input("searchSubDirectories", "Optional input to determine whether settings should be loaded from the given directory AND all sub-directories (if they exist). Defaults to false, meaning only settings file in the given directory will be loaded.")]
public static void LoadSettings(string settingsFolder = null, string fileFilter = "*.json", bool forceLoad = false, bool searchSubDirectories = false)
{
if (string.IsNullOrEmpty(settingsFolder))
settingsFolder = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData), "BHoM", "Settings"); //Defaults to C:/ProgramData/BHoM/Settings if no folder is provided
Expand All @@ -48,7 +49,8 @@ public static void LoadSettings(string settingsFolder = null, string fileFilter
if (Global.BHoMSettingsLoaded.Contains(fullSettingsLoadedKey) && !forceLoad)
return; //Settings from this folder have already been loaded, and we're not force loading them, so don't waste time reloading them

var settingsFiles = Directory.EnumerateFiles(settingsFolder, fileFilter, SearchOption.AllDirectories);
var searchOption = (searchSubDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
var settingsFiles = Directory.EnumerateFiles(settingsFolder, fileFilter, searchOption);

foreach (var file in settingsFiles)
{
Expand Down
Loading