mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Force save favicon icons & Fix svg save issue
This commit is contained in:
parent
4f246460c3
commit
ba0205f471
2 changed files with 20 additions and 9 deletions
|
|
@ -177,11 +177,9 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
|
|||
if (imageData is not { Length: > 0 })
|
||||
continue;
|
||||
|
||||
var faviconPath = Path.Combine(_faviconCacheDir, $"{domain}_{iconId}.png");
|
||||
if (!File.Exists(faviconPath))
|
||||
{
|
||||
SaveBitmapData(imageData, faviconPath);
|
||||
}
|
||||
var faviconPath = Path.Combine(_faviconCacheDir, $"chromium_{domain}_{iconId}.png");
|
||||
SaveBitmapData(imageData, faviconPath);
|
||||
|
||||
bookmark.FaviconPath = faviconPath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -155,12 +155,16 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
|
|||
if (imageData is not { Length: > 0 })
|
||||
continue;
|
||||
|
||||
var faviconPath = Path.Combine(_faviconCacheDir, $"firefox_{domain}.png");
|
||||
|
||||
if (!File.Exists(faviconPath))
|
||||
string faviconPath;
|
||||
if (IsSvgData(imageData))
|
||||
{
|
||||
SaveBitmapData(imageData, faviconPath);
|
||||
faviconPath = Path.Combine(_faviconCacheDir, $"firefox_{domain}.svg");
|
||||
}
|
||||
else
|
||||
{
|
||||
faviconPath = Path.Combine(_faviconCacheDir, $"firefox_{domain}.png");
|
||||
}
|
||||
SaveBitmapData(imageData, faviconPath);
|
||||
|
||||
bookmark.FaviconPath = faviconPath;
|
||||
}
|
||||
|
|
@ -201,6 +205,15 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
|
|||
Main._context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsSvgData(byte[] data)
|
||||
{
|
||||
if (data.Length < 5)
|
||||
return false;
|
||||
string start = System.Text.Encoding.ASCII.GetString(data, 0, Math.Min(100, data.Length));
|
||||
return start.Contains("<svg") ||
|
||||
(start.StartsWith("<?xml") && start.Contains("<svg"));
|
||||
}
|
||||
}
|
||||
|
||||
public class FirefoxBookmarkLoader : FirefoxBookmarkLoaderBase
|
||||
|
|
|
|||
Loading…
Reference in a new issue