diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index c2c3ec36d..130221379 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -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) diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index fa5005078..f2d9323ef 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -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; } }