Skip to content

Commit

Permalink
allow custom nodes to load in service mode (DynamoDS#15551)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkkirschner authored Oct 17, 2024
1 parent da45f11 commit 7ae94ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,11 +1472,18 @@ private void InitializeCustomNodeManager()
var customNodeSearchRegistry = new HashSet<Guid>();
CustomNodeManager.InfoUpdated += info =>
{
//just bail in service mode.
if (IsServiceMode)
{
return;
}

if (customNodeSearchRegistry.Contains(info.FunctionId)
|| !info.IsVisibleInDynamoLibrary)
return;

var elements = SearchModel.Entries.OfType<CustomNodeSearchElement>().

var elements = SearchModel?.Entries.OfType<CustomNodeSearchElement>().
Where(x =>
{
// Search for common paths and get rid of empty paths.
Expand All @@ -1494,6 +1501,7 @@ private void InitializeCustomNodeManager()
}
return;
}


customNodeSearchRegistry.Add(info.FunctionId);
var searchElement = new CustomNodeSearchElement(CustomNodeManager, info);
Expand Down Expand Up @@ -1530,6 +1538,7 @@ private void InitializeCustomNodeManager()
}
};
};

CustomNodeManager.DefinitionUpdated += UpdateCustomNodeDefinition;
}

Expand Down Expand Up @@ -2807,7 +2816,7 @@ internal void DumpLibraryToXml(object parameter)
string fileName = String.Format("LibrarySnapshot_{0}.xml", DateTime.Now.ToString("yyyyMMddHmmss"));
string fullFileName = Path.Combine(pathManager.LogDirectory, fileName);

SearchModel.DumpLibraryToXml(fullFileName, PathManager.DynamoCoreDirectory);
SearchModel?.DumpLibraryToXml(fullFileName, PathManager.DynamoCoreDirectory);

Logger.Log(string.Format(Resources.LibraryIsDumped, fullFileName));
}
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCore/Utilities/LuceneSearchUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ internal string CreateSearchQuery(string[] fields, string SearchTerm, bool IsPac
foreach (string s in searchTerm.Split(' '))
{
//If is a ByEmptySpace search and the split words match with more than MaxNodeNamesRepeated nodes then the word is skipped (otherwise the results will be polluted with hundred of not related nodes)
int nodesFrequency = dynamoModel.SearchModel.Entries.Where(entry => entry.Name.ToLower().Contains(s) && !string.IsNullOrEmpty(s)).Count();
int? nodesFrequency = dynamoModel.SearchModel?.Entries.Where(entry => entry.Name.ToLower().Contains(s) && !string.IsNullOrEmpty(s)).Count();
if (nodesFrequency > MaxNodeNamesRepeated) continue;

if (string.IsNullOrEmpty(s)) continue;
Expand Down

0 comments on commit 7ae94ea

Please sign in to comment.