Skip to content

Commit

Permalink
Merge pull request #2335 from ktos/bookmarks-newsqlite
Browse files Browse the repository at this point in the history
Switch Bookmarks plugin to use Microsoft.Data.Sqlite
  • Loading branch information
jjw24 authored Oct 24, 2023
2 parents c202356 + ab96629 commit 026e5f5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
13 changes: 12 additions & 1 deletion Flow.Launcher.Core/Plugin/PluginAssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,22 @@ protected override Assembly Load(AssemblyName assemblyName)

return existAssembly ?? (assemblyPath == null ? null : LoadFromAssemblyPath(assemblyPath));
}

protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
{
var path = dependencyResolver.ResolveUnmanagedDllToPath(unmanagedDllName);
if (!string.IsNullOrEmpty(path))
{
return LoadUnmanagedDllFromPath(path);
}

return IntPtr.Zero;
}

internal Type FromAssemblyGetTypeOfInterface(Assembly assembly, Type type)
{
var allTypes = assembly.ExportedTypes;
return allTypes.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Any(t => t == type));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Flow.Launcher.Plugin.BrowserBookmark.Models;
using Microsoft.Data.Sqlite;
using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.IO;
using System.Linq;

Expand All @@ -19,7 +19,7 @@ INNER JOIN moz_bookmarks ON (
ORDER BY moz_places.visit_count DESC
";

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

protected static List<Bookmark> GetBookmarksFromPath(string placesPath)
{
Expand All @@ -33,11 +33,11 @@ protected static List<Bookmark> GetBookmarksFromPath(string placesPath)

// create the connection string and init the connection
string dbPath = string.Format(dbPathFormat, placesPath);
using var dbConnection = new SQLiteConnection(dbPath);
using var dbConnection = new SqliteConnection(dbPath);
// Open connection to the database file and execute the query
dbConnection.Open();
var reader = new SQLiteCommand(queryAllBookmarks, dbConnection).ExecuteReader();

var reader = new SqliteCommand(queryAllBookmarks, dbConnection).ExecuteReader();
// return results in List<Bookmark> format
bookmarkList = reader.Select(
x => new Bookmark(x["title"] is DBNull ? string.Empty : x["title"].ToString(),
Expand Down Expand Up @@ -133,7 +133,7 @@ Current profiles.ini structure example as of Firefox version 69.0.1

public static class Extensions
{
public static IEnumerable<T> Select<T>(this SQLiteDataReader reader, Func<SQLiteDataReader, T> projection)
public static IEnumerable<T> Select<T>(this SqliteDataReader reader, Func<SqliteDataReader, T> projection)
{
while (reader.Read())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
Expand Down Expand Up @@ -56,22 +56,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.10" />
</ItemGroup>

<ItemGroup>
<Compile Remove="Bookmark.cs" />
</ItemGroup>

<Target Name="CopyDLLs" AfterTargets="Build">
<Message Text="Executing CopyDLLs task" Importance="High" />
<Copy SourceFiles="$(TargetDir)\runtimes\win-x64\native\SQLite.Interop.dll" DestinationFolder="$(TargetDir)\x64" />
<Copy SourceFiles="$(TargetDir)\runtimes\win-x86\native\SQLite.Interop.dll" DestinationFolder="$(TargetDir)\x86" />
</Target>

<Target Name="DeleteRuntimesFolder" AfterTargets="CopyDLLs">
<Message Text="Deleting runtimes folder" Importance="High" />
<RemoveDir Directories="$(TargetDir)\runtimes" />
</Target>

</Project>

0 comments on commit 026e5f5

Please sign in to comment.