Skip to content

Commit d9b43ee

Browse files
committed
Use Uri instead of full FileStream for cached local file
1 parent 7387499 commit d9b43ee

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

BackgroundTest/CustomControl/LayeredBackgroundImage/LayeredBackgroundImageExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ internal async ValueTask<bool> LoadImageAsync(Uri? sourceFromP
6565
return false;
6666
}
6767

68-
Uri? cachedUrlSource = null;
68+
Uri? cachedUrlSource = cacheResult.CachedSource as Uri;
6969
Stream? cachedStreamSource = null;
7070

7171
if (cacheResult.CachedSource is string asString)

BackgroundTest/TestMediaCacheHandler.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,11 @@ public async Task<MediaCacheResult> LoadCachedSource(object? sourceObject)
3232

3333
if (sourceUrl?.IsFile ?? false)
3434
{
35-
string normalizedPath = sourceUrl.LocalPath;
36-
if (File.Exists(normalizedPath))
35+
return new MediaCacheResult()
3736
{
38-
return new MediaCacheResult
39-
{
40-
ForceUseInternalDecoder = false,
41-
CachedSource = File.Open(normalizedPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite),
42-
DisposeStream = true
43-
};
44-
}
45-
46-
return null!;
37+
CachedSource = sourceUrl,
38+
DisposeStream = true
39+
};
4740
}
4841

4942
string extension = Path.GetExtension(absolutePath);
@@ -59,7 +52,7 @@ public async Task<MediaCacheResult> LoadCachedSource(object? sourceObject)
5952
return new MediaCacheResult
6053
{
6154
ForceUseInternalDecoder = forceInternalCodec,
62-
CachedSource = File.Open(tempPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite),
55+
CachedSource = new Uri(tempPath),
6356
DisposeStream = true
6457
};
6558
}

0 commit comments

Comments
 (0)