Skip to content

Commit 026e5f5

Browse files
authored
Merge pull request #2335 from ktos/bookmarks-newsqlite
Switch Bookmarks plugin to use Microsoft.Data.Sqlite
2 parents c202356 + ab96629 commit 026e5f5

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

Flow.Launcher.Core/Plugin/PluginAssemblyLoader.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,22 @@ protected override Assembly Load(AssemblyName assemblyName)
3434

3535
return existAssembly ?? (assemblyPath == null ? null : LoadFromAssemblyPath(assemblyPath));
3636
}
37+
38+
protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
39+
{
40+
var path = dependencyResolver.ResolveUnmanagedDllToPath(unmanagedDllName);
41+
if (!string.IsNullOrEmpty(path))
42+
{
43+
return LoadUnmanagedDllFromPath(path);
44+
}
45+
46+
return IntPtr.Zero;
47+
}
3748

3849
internal Type FromAssemblyGetTypeOfInterface(Assembly assembly, Type type)
3950
{
4051
var allTypes = assembly.ExportedTypes;
4152
return allTypes.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Any(t => t == type));
4253
}
4354
}
44-
}
55+
}

Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Flow.Launcher.Plugin.BrowserBookmark.Models;
2+
using Microsoft.Data.Sqlite;
23
using System;
34
using System.Collections.Generic;
4-
using System.Data.SQLite;
55
using System.IO;
66
using System.Linq;
77

@@ -19,7 +19,7 @@ INNER JOIN moz_bookmarks ON (
1919
ORDER BY moz_places.visit_count DESC
2020
";
2121

22-
private const string dbPathFormat = "Data Source ={0};Version=3;New=False;Compress=True;";
22+
private const string dbPathFormat = "Data Source ={0}";
2323

2424
protected static List<Bookmark> GetBookmarksFromPath(string placesPath)
2525
{
@@ -33,11 +33,11 @@ protected static List<Bookmark> GetBookmarksFromPath(string placesPath)
3333

3434
// create the connection string and init the connection
3535
string dbPath = string.Format(dbPathFormat, placesPath);
36-
using var dbConnection = new SQLiteConnection(dbPath);
36+
using var dbConnection = new SqliteConnection(dbPath);
3737
// Open connection to the database file and execute the query
3838
dbConnection.Open();
39-
var reader = new SQLiteCommand(queryAllBookmarks, dbConnection).ExecuteReader();
40-
39+
var reader = new SqliteCommand(queryAllBookmarks, dbConnection).ExecuteReader();
40+
4141
// return results in List<Bookmark> format
4242
bookmarkList = reader.Select(
4343
x => new Bookmark(x["title"] is DBNull ? string.Empty : x["title"].ToString(),
@@ -133,7 +133,7 @@ Current profiles.ini structure example as of Firefox version 69.0.1
133133

134134
public static class Extensions
135135
{
136-
public static IEnumerable<T> Select<T>(this SQLiteDataReader reader, Func<SQLiteDataReader, T> projection)
136+
public static IEnumerable<T> Select<T>(this SqliteDataReader reader, Func<SqliteDataReader, T> projection)
137137
{
138138
while (reader.Read())
139139
{

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
@@ -56,22 +56,7 @@
5656
</ItemGroup>
5757

5858
<ItemGroup>
59-
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
59+
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.10" />
6060
</ItemGroup>
6161

62-
<ItemGroup>
63-
<Compile Remove="Bookmark.cs" />
64-
</ItemGroup>
65-
66-
<Target Name="CopyDLLs" AfterTargets="Build">
67-
<Message Text="Executing CopyDLLs task" Importance="High" />
68-
<Copy SourceFiles="$(TargetDir)\runtimes\win-x64\native\SQLite.Interop.dll" DestinationFolder="$(TargetDir)\x64" />
69-
<Copy SourceFiles="$(TargetDir)\runtimes\win-x86\native\SQLite.Interop.dll" DestinationFolder="$(TargetDir)\x86" />
70-
</Target>
71-
72-
<Target Name="DeleteRuntimesFolder" AfterTargets="CopyDLLs">
73-
<Message Text="Deleting runtimes folder" Importance="High" />
74-
<RemoveDir Directories="$(TargetDir)\runtimes" />
75-
</Target>
76-
7762
</Project>

0 commit comments

Comments
 (0)