Fix sqlite file lock issue & Add static

This commit is contained in:
Jack251970 2025-03-20 16:11:22 +08:00
parent fab983396f
commit a87211bfb4
2 changed files with 13 additions and 7 deletions

View file

@ -63,7 +63,7 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
return bookmarks;
}
protected List<Bookmark> LoadBookmarksFromFile(string path, string source)
protected static List<Bookmark> LoadBookmarksFromFile(string path, string source)
{
var bookmarks = new List<Bookmark>();
@ -77,7 +77,7 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
return bookmarks;
}
private void EnumerateRoot(JsonElement rootElement, ICollection<Bookmark> bookmarks, string source)
private static void EnumerateRoot(JsonElement rootElement, ICollection<Bookmark> bookmarks, string source)
{
foreach (var folder in rootElement.EnumerateObject())
{
@ -92,7 +92,7 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
}
}
private void EnumerateFolderBookmark(JsonElement folderElement, ICollection<Bookmark> bookmarks,
private static void EnumerateFolderBookmark(JsonElement folderElement, ICollection<Bookmark> bookmarks,
string source)
{
if (!folderElement.TryGetProperty("children", out var childrenElement))
@ -201,6 +201,8 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
// Delete temporary file
try
{
// https://github.com/dotnet/efcore/issues/26580
SqliteConnection.ClearAllPools();
File.Delete(tempDbPath);
}
catch (Exception ex)
@ -214,7 +216,7 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
}
}
private void SaveBitmapData(byte[] imageData, string outputPath)
private static void SaveBitmapData(byte[] imageData, string outputPath)
{
try
{

View file

@ -86,6 +86,8 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
// Delete temporary file
try
{
// https://github.com/dotnet/efcore/issues/26580
SqliteConnection.ClearAllPools();
File.Delete(tempDbPath);
}
catch (Exception ex)
@ -168,6 +170,8 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
// Delete temporary file
try
{
// https://github.com/dotnet/efcore/issues/26580
SqliteConnection.ClearAllPools();
File.Delete(tempDbPath);
}
catch (Exception ex)
@ -181,7 +185,7 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
}
}
private bool IsSvgData(byte[] data)
private static bool IsSvgData(byte[] data)
{
if (data == null || data.Length < 5)
return false;
@ -195,7 +199,7 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
header.Contains("image/svg+xml");
}
private void SaveBitmapData(byte[] imageData, string outputPath)
private static void SaveBitmapData(byte[] imageData, string outputPath)
{
try
{
@ -221,7 +225,7 @@ public class FirefoxBookmarkLoader : FirefoxBookmarkLoaderBase
/// <summary>
/// Path to places.sqlite
/// </summary>
private string PlacesPath
private static string PlacesPath
{
get
{