@@ -45,16 +45,14 @@ public ThumbnailCacheModel(int maxEntries)
4545 /// Tries to get a cached thumbnail for the specified file.
4646 /// The cache key includes the file's modification date, so modified files automatically get new thumbnails.
4747 /// </summary>
48- /// <param name="file">The file to get the cached thumbnail for .</param>
48+ /// <param name="cacheKey">A unique cache ID .</param>
4949 /// <param name="cancellationToken">A <see cref="CancellationToken"/> that cancels this action.</param>
5050 /// <returns>A <see cref="Task"/> that represents the asynchronous operation. Value is the cached thumbnail stream if found, otherwise null.</returns>
51- public async Task < Stream ? > TryGetCachedThumbnailAsync ( IFile file , CancellationToken cancellationToken = default )
51+ public async Task < Stream ? > TryGetCachedThumbnailAsync ( string cacheKey , CancellationToken cancellationToken = default )
5252 {
5353 try
5454 {
55- var cacheKey = await GetCacheKeyAsync ( file , cancellationToken ) ;
5655 var cachedData = await _database . GetValueAsync < byte [ ] > ( cacheKey , cancellationToken : cancellationToken ) ;
57-
5856 if ( cachedData is null || cachedData . Length == 0 )
5957 return null ;
6058
@@ -70,16 +68,14 @@ public ThumbnailCacheModel(int maxEntries)
7068 /// Caches the thumbnail for the specified file.
7169 /// The cache key includes the file's modification date, ensuring modified files get fresh thumbnails.
7270 /// </summary>
73- /// <param name="file">The file to cache the thumbnail for .</param>
71+ /// <param name="cacheKey">A unique cache ID .</param>
7472 /// <param name="thumbnailStream">The thumbnail stream to cache.</param>
7573 /// <param name="cancellationToken">A <see cref="CancellationToken"/> that cancels this action.</param>
7674 /// <returns>A <see cref="Task"/> that represents the asynchronous operation.</returns>
77- public async Task CacheThumbnailAsync ( IFile file , IImageStream thumbnailStream , CancellationToken cancellationToken = default )
75+ public async Task CacheThumbnailAsync ( string cacheKey , IImageStream thumbnailStream , CancellationToken cancellationToken = default )
7876 {
7977 try
8078 {
81- var cacheKey = await GetCacheKeyAsync ( file , cancellationToken ) ;
82-
8379 // Copy thumbnail to byte array
8480 using var memoryStream = new MemoryStream ( ) ;
8581 await thumbnailStream . CopyToAsync ( memoryStream , cancellationToken ) ;
@@ -111,7 +107,7 @@ public Task ClearCacheAsync(CancellationToken cancellationToken = default)
111107 /// <param name="file">The file to generate a cache key for.</param>
112108 /// <param name="cancellationToken">A <see cref="CancellationToken"/> that cancels this action.</param>
113109 /// <returns>A unique cache key string.</returns>
114- private static async Task < string > GetCacheKeyAsync ( IFile file , CancellationToken cancellationToken )
110+ public static async Task < string > GetCacheKeyAsync ( IFile file , CancellationToken cancellationToken )
115111 {
116112 var pathHash = GetPathHash ( file . Id ) ;
117113 var dateModified = await file . GetDateModifiedAsync ( cancellationToken ) ;
0 commit comments