remove PluginDirectory, ImageLoader path checking, update IcoPath logic

This commit is contained in:
Jeremy Wu 2022-11-24 17:31:00 +11:00
parent 3665bd9efc
commit 83ec8099a7
2 changed files with 14 additions and 23 deletions

View file

@ -113,10 +113,12 @@ namespace Flow.Launcher.Infrastructure.Image
{
return new ImageResult(DefaultImage, ImageType.Error);
}
if (ImageCache.ContainsKey(path, loadFullImage))
{
return new ImageResult(ImageCache[path, loadFullImage], ImageType.Cache);
}
if (Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out var uriResult)
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps))
{
@ -131,11 +133,6 @@ namespace Flow.Launcher.Infrastructure.Image
return new ImageResult(imageSource, ImageType.Data);
}
if (!Path.IsPathRooted(path))
{
path = Path.Combine(Constant.ProgramDirectory, "Images", Path.GetFileName(path));
}
imageResult = await Task.Run(() => GetThumbnailResult(ref path, loadFullImage));
}
catch (System.Exception e)

View file

@ -60,15 +60,14 @@ namespace Flow.Launcher.Plugin
get { return _icoPath; }
set
{
if (!string.IsNullOrEmpty(PluginDirectory) && !Path.IsPathRooted(value))
// As a standard this property will handle prepping and converting to absolute local path for icon image processing
if (!string.IsNullOrEmpty(value)
&& !string.IsNullOrEmpty(PluginDirectory)
&& !Path.IsPathRooted(value)
&& !value.StartsWith("http://", StringComparison.OrdinalIgnoreCase)
&& !value.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
{
string absPath = Path.Combine(value, IcoPath);
// Only convert relative paths if its a valid path
if (File.Exists(absPath))
{
_icoPath = Path.Combine(value, IcoPath);
}
_icoPath = Path.Combine(PluginDirectory, value);
}
else
{
@ -146,16 +145,11 @@ namespace Flow.Launcher.Plugin
set
{
_pluginDirectory = value;
if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath))
{
string absPath = Path.Combine(value, IcoPath);
// Only convert relative paths if its a valid path
if (File.Exists(absPath))
{
IcoPath = absPath;
}
}
// When the Result object is returned from the query call, PluginDirectory is not provided until
// UpdatePluginMetadata call is made at PluginManager.cs L196. Once the PluginDirectory becomes available
// we need to update (only if not Uri path) the IcoPath with the full absolute path so the image can be loaded.
IcoPath = _icoPath;
}
}