Preload SQLite native lib from extension dir (0.15.13).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using SQLitePCL;
|
using SQLitePCL;
|
||||||
|
|
||||||
@@ -5,7 +8,9 @@ namespace Mrleo1nid.SwarmAssistent;
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SwarmUI loads extensions in an isolated AssemblyLoadContext — Microsoft.Data.Sqlite
|
/// SwarmUI loads extensions in an isolated AssemblyLoadContext — Microsoft.Data.Sqlite
|
||||||
/// does not auto-init native SQLite there. Call once before the first connection.
|
/// does not auto-init native SQLite there. Native libs ship under the extension dir
|
||||||
|
/// (runtimes/linux-x64/native/libe_sqlite3.so), but the loader searches the host
|
||||||
|
/// base dir unless we preload from the extension assembly location.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static class AssistentSqliteBootstrap
|
internal static class AssistentSqliteBootstrap
|
||||||
{
|
{
|
||||||
@@ -17,6 +22,42 @@ internal static class AssistentSqliteBootstrap
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
PreloadNativeLibrary();
|
||||||
Batteries_V2.Init();
|
Batteries_V2.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PreloadNativeLibrary()
|
||||||
|
{
|
||||||
|
string extDir = Path.GetDirectoryName(typeof(AssistentSqliteBootstrap).Assembly.Location)
|
||||||
|
?? AppContext.BaseDirectory
|
||||||
|
?? "";
|
||||||
|
if (string.IsNullOrWhiteSpace(extDir))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string[] relPaths =
|
||||||
|
[
|
||||||
|
Path.Combine("runtimes", "linux-x64", "native", "libe_sqlite3.so"),
|
||||||
|
Path.Combine("runtimes", "linux-x64", "native", "e_sqlite3.so"),
|
||||||
|
"libe_sqlite3.so",
|
||||||
|
"e_sqlite3.so",
|
||||||
|
];
|
||||||
|
foreach (string rel in relPaths)
|
||||||
|
{
|
||||||
|
string path = Path.Combine(extDir, rel);
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NativeLibrary.Load(path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SwarmUI.Utils.Logs.Debug($"AssistentSqliteBootstrap: NativeLibrary.Load({path}): {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public partial class SwarmAssistentExtension : Extension
|
|||||||
ExtensionAuthor = "mrleo1nid";
|
ExtensionAuthor = "mrleo1nid";
|
||||||
Description = "Collaborative Krea 2 assistant: Ollama chat, persona presets, vector memory, model cards, Generate loop.";
|
Description = "Collaborative Krea 2 assistant: Ollama chat, persona presets, vector memory, model cards, Generate loop.";
|
||||||
License = "MIT";
|
License = "MIT";
|
||||||
Version = "0.15.12";
|
Version = "0.15.13";
|
||||||
Tags = ["tabs", "ui", "llm", "ollama", "krea", "inpaint", "memory", "training", "heard", "qlora"];
|
Tags = ["tabs", "ui", "llm", "ollama", "krea", "inpaint", "memory", "training", "heard", "qlora"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
AND !$([System.String]::Copy('%(ReferenceCopyLocalPaths.NuGetPackageId)').StartsWith('SQLitePCLRaw'))" />
|
AND !$([System.String]::Copy('%(ReferenceCopyLocalPaths.NuGetPackageId)').StartsWith('SQLitePCLRaw'))" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
<!-- Native libe_sqlite3 for Linux — ReferenceCopyLocalPaths alone is not enough. -->
|
<!-- Native libe_sqlite3 for Linux — also copy flat names the loader probes. -->
|
||||||
<Target Name="CopySqliteNativeRuntimes" AfterTargets="Build">
|
<Target Name="CopySqliteNativeRuntimes" AfterTargets="Build">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<_SqliteNative Include="@(RuntimeCopyLocalItems)"
|
<_SqliteNative Include="@(RuntimeCopyLocalItems)"
|
||||||
@@ -32,5 +32,13 @@
|
|||||||
DestinationFiles="$(OutputPath)@(_SqliteNative->'%(RuntimeCopyLocalItems.DestinationSubPath)')"
|
DestinationFiles="$(OutputPath)@(_SqliteNative->'%(RuntimeCopyLocalItems.DestinationSubPath)')"
|
||||||
SkipUnchangedFiles="true"
|
SkipUnchangedFiles="true"
|
||||||
Condition="'@(_SqliteNative)' != ''" />
|
Condition="'@(_SqliteNative)' != ''" />
|
||||||
|
<Copy SourceFiles="@(_SqliteNative)"
|
||||||
|
DestinationFiles="$(OutputPath)%(Filename)%(Extension)"
|
||||||
|
SkipUnchangedFiles="true"
|
||||||
|
Condition="'@(_SqliteNative)' != '' and $([System.String]::Copy('%(RuntimeCopyLocalItems.DestinationSubPath)').Contains('linux-x64'))" />
|
||||||
|
<Copy SourceFiles="@(_SqliteNative)"
|
||||||
|
DestinationFiles="$(OutputPath)e_sqlite3%(Extension)"
|
||||||
|
SkipUnchangedFiles="true"
|
||||||
|
Condition="'@(_SqliteNative)' != '' and $([System.String]::Copy('%(RuntimeCopyLocalItems.DestinationSubPath)').Contains('linux-x64')) and $([System.String]::Copy('%(Filename)').Contains('libe_sqlite3'))" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user