Skip to content

Commit 71f1acd

Browse files
committed
Revert com expcetion & Add thumbnail only check
1 parent 38b2850 commit 71f1acd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Flow.Launcher.Infrastructure/Image/ThumbnailReader.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class WindowsThumbnailProvider
3131

3232
private static readonly Guid GUID_IShellItem = typeof(IShellItem).GUID;
3333

34+
private static readonly HRESULT S_ExtractionFailed = (HRESULT)0x8004B200;
35+
3436
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
3537
{
3638
HBITMAP hBitmap = GetHBitmap(Path.GetFullPath(fileName), width, height, options);
@@ -77,12 +79,12 @@ private static unsafe HBITMAP GetHBitmap(string fileName, int width, int height,
7779
{
7880
imageFactory.GetImage(size, (SIIGBF)options, &hBitmap);
7981
}
80-
catch (COMException)
82+
catch (COMException ex) when (ex.HResult == S_ExtractionFailed && options == ThumbnailOptions.ThumbnailOnly)
8183
{
82-
// Fallback to IconOnly for COM exceptions
84+
// Fallback to IconOnly if ThumbnailOnly fails
8385
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);
8486
}
85-
catch (FileNotFoundException)
87+
catch (FileNotFoundException) when (options == ThumbnailOptions.ThumbnailOnly)
8688
{
8789
// Fallback to IconOnly if files cannot be found
8890
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);

0 commit comments

Comments
 (0)