Skip to content

Commit 83ec809

Browse files
committed
remove PluginDirectory, ImageLoader path checking, update IcoPath logic
1 parent 3665bd9 commit 83ec809

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,12 @@ private static async ValueTask<ImageResult> LoadInternalAsync(string path, bool
113113
{
114114
return new ImageResult(DefaultImage, ImageType.Error);
115115
}
116+
116117
if (ImageCache.ContainsKey(path, loadFullImage))
117118
{
118119
return new ImageResult(ImageCache[path, loadFullImage], ImageType.Cache);
119120
}
121+
120122
if (Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out var uriResult)
121123
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps))
122124
{
@@ -131,11 +133,6 @@ private static async ValueTask<ImageResult> LoadInternalAsync(string path, bool
131133
return new ImageResult(imageSource, ImageType.Data);
132134
}
133135

134-
if (!Path.IsPathRooted(path))
135-
{
136-
path = Path.Combine(Constant.ProgramDirectory, "Images", Path.GetFileName(path));
137-
}
138-
139136
imageResult = await Task.Run(() => GetThumbnailResult(ref path, loadFullImage));
140137
}
141138
catch (System.Exception e)

Flow.Launcher.Plugin/Result.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,14 @@ public string IcoPath
6060
get { return _icoPath; }
6161
set
6262
{
63-
if (!string.IsNullOrEmpty(PluginDirectory) && !Path.IsPathRooted(value))
63+
// As a standard this property will handle prepping and converting to absolute local path for icon image processing
64+
if (!string.IsNullOrEmpty(value)
65+
&& !string.IsNullOrEmpty(PluginDirectory)
66+
&& !Path.IsPathRooted(value)
67+
&& !value.StartsWith("http://", StringComparison.OrdinalIgnoreCase)
68+
&& !value.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
6469
{
65-
string absPath = Path.Combine(value, IcoPath);
66-
// Only convert relative paths if its a valid path
67-
if (File.Exists(absPath))
68-
{
69-
_icoPath = Path.Combine(value, IcoPath);
70-
}
71-
70+
_icoPath = Path.Combine(PluginDirectory, value);
7271
}
7372
else
7473
{
@@ -146,16 +145,11 @@ public string PluginDirectory
146145
set
147146
{
148147
_pluginDirectory = value;
149-
if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath))
150-
{
151-
string absPath = Path.Combine(value, IcoPath);
152-
// Only convert relative paths if its a valid path
153-
if (File.Exists(absPath))
154-
{
155-
IcoPath = absPath;
156-
}
157-
158-
}
148+
149+
// When the Result object is returned from the query call, PluginDirectory is not provided until
150+
// UpdatePluginMetadata call is made at PluginManager.cs L196. Once the PluginDirectory becomes available
151+
// we need to update (only if not Uri path) the IcoPath with the full absolute path so the image can be loaded.
152+
IcoPath = _icoPath;
159153
}
160154
}
161155

0 commit comments

Comments
 (0)