From 82263c1d2f4bd883d00d473f377f324774479f50 Mon Sep 17 00:00:00 2001 From: Antonios Makropoulos Date: Wed, 25 Sep 2024 23:35:12 +0300 Subject: [PATCH 1/2] fix windows locking of dlls --- Runtime/LLMBuilder.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Runtime/LLMBuilder.cs b/Runtime/LLMBuilder.cs index 542520f9..5b2fc278 100644 --- a/Runtime/LLMBuilder.cs +++ b/Runtime/LLMBuilder.cs @@ -17,12 +17,12 @@ private static void InitializeOnLoad() { Reset(); } - - public static void CopyPath(string source, string target) + + public static void HandleActionFileRecursive(string source, string target, ActionCallback actionCallback) { if (File.Exists(source)) { - File.Copy(source, target, true); + actionCallback(source, target); } else if (Directory.Exists(source)) { @@ -32,14 +32,24 @@ public static void CopyPath(string source, string target) filesAndDirs.AddRange(Directory.GetDirectories(source)); foreach (string path in filesAndDirs) { - CopyPath(path, Path.Combine(target, Path.GetFileName(path))); + HandleActionFileRecursive(path, Path.Combine(target, Path.GetFileName(path)), actionCallback); } } } + public static void CopyWithOverwrite(string source, string target) + { + File.Copy(source, target, true); + } + + public static void CopyPath(string source, string target) + { + HandleActionFileRecursive(source, target, CopyWithOverwrite); + } + public static void MovePath(string source, string target) { - CopyPath(source, target); + HandleActionFileRecursive(source, target, File.Move); DeletePath(source); } From f80ed1ce018338e7f8964ba4e8fff9434f0d2081 Mon Sep 17 00:00:00 2001 From: Antonis Makropoulos Date: Wed, 25 Sep 2024 23:42:13 +0300 Subject: [PATCH 2/2] free archChecker after use --- Runtime/LLMLib.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Runtime/LLMLib.cs b/Runtime/LLMLib.cs index bb7417c7..0732846a 100644 --- a/Runtime/LLMLib.cs +++ b/Runtime/LLMLib.cs @@ -303,6 +303,7 @@ static LLMLib() has_avx = LibraryLoader.GetSymbolDelegate(archCheckerHandle, "has_avx")(); has_avx2 = LibraryLoader.GetSymbolDelegate(archCheckerHandle, "has_avx2")(); has_avx512 = LibraryLoader.GetSymbolDelegate(archCheckerHandle, "has_avx512")(); + LibraryLoader.FreeLibrary(archCheckerHandle); } catch (Exception e) {