Use plugin cache directory

This commit is contained in:
Jack251970 2025-04-02 22:39:30 +08:00
parent b564a39aae
commit a845e68c98
3 changed files with 12 additions and 9 deletions

View file

@ -10,16 +10,13 @@ namespace Flow.Launcher.Plugin.BrowserBookmark;
public abstract class ChromiumBookmarkLoader : IBookmarkLoader
{
private readonly static string ClassName = nameof(ChromiumBookmarkLoader);
private static readonly string ClassName = nameof(ChromiumBookmarkLoader);
private readonly string _faviconCacheDir;
protected ChromiumBookmarkLoader()
{
_faviconCacheDir = Path.Combine(
Path.GetDirectoryName(typeof(ChromiumBookmarkLoader).Assembly.Location),
"FaviconCache");
Directory.CreateDirectory(_faviconCacheDir);
_faviconCacheDir = Main._faviconCacheDir;
}
public abstract List<Bookmark> GetBookmarks();

View file

@ -15,10 +15,7 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
protected FirefoxBookmarkLoaderBase()
{
_faviconCacheDir = Path.Combine(
Path.GetDirectoryName(typeof(FirefoxBookmarkLoaderBase).Assembly.Location),
"FaviconCache");
Directory.CreateDirectory(_faviconCacheDir);
_faviconCacheDir = Main._faviconCacheDir;
}
public abstract List<Bookmark> GetBookmarks();

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Plugin.BrowserBookmark.Commands;
using Flow.Launcher.Plugin.BrowserBookmark.Models;
using Flow.Launcher.Plugin.BrowserBookmark.Views;
@ -14,6 +15,8 @@ namespace Flow.Launcher.Plugin.BrowserBookmark;
public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContextMenu, IDisposable
{
internal static string _faviconCacheDir;
internal static PluginInitContext _context;
private static List<Bookmark> _cachedBookmarks = new();
@ -28,6 +31,12 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex
_settings = context.API.LoadSettingJsonStorage<Settings>();
_faviconCacheDir = Path.Combine(
_context.CurrentPluginMetadata.PluginCacheDirectoryPath,
"FaviconCache");
Helper.ValidateDirectory(_faviconCacheDir);
LoadBookmarksIfEnabled();
}