From f668a93f84c18a03f33c330c796a134a1554fb77 Mon Sep 17 00:00:00 2001 From: redth Date: Thu, 16 Mar 2023 23:36:47 -0400 Subject: [PATCH] Check bundle paths in file resolver --- .../DataResolvers/FileDataResolver.cs | 29 +++++++++++++++++-- .../iOS/DataResolvers/FileDataResolver.cs | 23 +++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/source/FFImageLoading/Platforms/MacCatalyst/DataResolvers/FileDataResolver.cs b/source/FFImageLoading/Platforms/MacCatalyst/DataResolvers/FileDataResolver.cs index 3c095f81..7578ae8e 100644 --- a/source/FFImageLoading/Platforms/MacCatalyst/DataResolvers/FileDataResolver.cs +++ b/source/FFImageLoading/Platforms/MacCatalyst/DataResolvers/FileDataResolver.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using FFImageLoading.Helpers; using System.Threading; +using Foundation; +using Microsoft.Maui.Storage; namespace FFImageLoading.DataResolvers { @@ -37,10 +39,31 @@ public virtual Task Resolve(string identifier, TaskParameter if (string.IsNullOrEmpty(file) && FileStore.Exists(identifier)) { - file = identifier; - } + file = identifier; + } + + // Let's check the bundle and bundle resource paths too + foreach (var bu in NSBundle._AllBundles) + { + var path = Path.Combine(bu.ResourcePath, identifier); + + if (File.Exists(path)) + { + file = path; + break; + } + + path = Path.Combine(bu.BundlePath, identifier); + + if (File.Exists(path)) + { + file = path; + break; + } + } + - token.ThrowIfCancellationRequested(); + token.ThrowIfCancellationRequested(); if (!string.IsNullOrEmpty(file)) { diff --git a/source/FFImageLoading/Platforms/iOS/DataResolvers/FileDataResolver.cs b/source/FFImageLoading/Platforms/iOS/DataResolvers/FileDataResolver.cs index 5c59c92b..74f615d5 100644 --- a/source/FFImageLoading/Platforms/iOS/DataResolvers/FileDataResolver.cs +++ b/source/FFImageLoading/Platforms/iOS/DataResolvers/FileDataResolver.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using FFImageLoading.Helpers; using System.Threading; +using Foundation; +using Microsoft.Maui.Storage; namespace FFImageLoading.DataResolvers { @@ -40,6 +42,27 @@ public virtual Task Resolve(string identifier, TaskParameter file = identifier; } + // Let's check the bundle and bundle resource paths too + foreach (var bu in NSBundle._AllBundles) + { + var path = Path.Combine(bu.ResourcePath, identifier); + + if (File.Exists(path)) + { + file = path; + break; + } + + path = Path.Combine(bu.BundlePath, identifier); + + if (File.Exists(path)) + { + file = path; + break; + } + } + + token.ThrowIfCancellationRequested(); if (!string.IsNullOrEmpty(file))