Skip to content

Commit

Permalink
Make sure package loading end will already release index lock
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongTang committed Oct 25, 2023
1 parent 1b8456c commit de04a5e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/DynamoCore/Utilities/LuceneSearchUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ internal void AddNodeTypeToSearchIndex(NodeSearchElement node, Document doc)
{
CreateLuceneIndexWriter(OpenMode.CREATE_OR_APPEND);
}
// If the index writer is still null, skip the indexing
if (writer == null) return;

SetDocumentFieldValue(doc, nameof(LuceneConfig.NodeFieldsEnum.FullCategoryName), node.FullCategoryName);
SetDocumentFieldValue(doc, nameof(LuceneConfig.NodeFieldsEnum.Name), node.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,8 @@ internal virtual void InstallPackage(PackageDownloadHandle packageDownloadHandle
}
}
SetPackageState(packageDownloadHandle, installPath);
// Dispose Index writer to avoid file lock
Search.LuceneSearch.LuceneUtilityNodeSearch.DisposeWriter();
Analytics.TrackEvent(Actions.Installed, Categories.PackageManagerOperations, $"{packageDownloadHandle?.Name}");
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Dynamo.Core;
Expand Down Expand Up @@ -266,6 +266,8 @@ private void CommitChanges(object param)
packageLoader.LoadNewCustomNodesAndPackages(newPaths, customNodeManager);
}
packagePathsEnabled.Clear();
// Dispose Index writer to avoid file lock
Search.LuceneSearch.LuceneUtilityNodeSearch.DisposeWriter();
}

internal void SetPackagesScheduledState(string packagePath, bool packagePathDisabled)
Expand Down
1 change: 1 addition & 0 deletions src/DynamoUtilities/PathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static Exception CreateFolderIfNotExist(string folderPath)
{
try
{
if (string.IsNullOrEmpty(folderPath)) return null;
// When network path is access denied, the Directory.Exits however still
// return true.
// EnumerateDirectories operation is additional check
Expand Down

0 comments on commit de04a5e

Please sign in to comment.