Skip to content

Switch Bookmarks plugin to use Microsoft.Data.Sqlite #2335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>