Skip to content

Commit

Permalink
fix(wadouri): Check cache when prefetching wadouri images for volume (#…
Browse files Browse the repository at this point in the history
…1765)

When using wadouri: scheme with streaming image volume loader, the first, middle and possibly last images must be cached so that the volume can be constructed from metadata. This change first checks if the required images are already in the cache before getting the loadPoolManager involved.
  • Loading branch information
jmhmd authored Jan 20, 2025
1 parent 44e782b commit 4f05843
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cache from '../cache/cache';
import StreamingImageVolume from '../cache/classes/StreamingImageVolume';
import { RequestType } from '../enums';
import imageLoadPoolManager from '../requestPool/imageLoadPoolManager';
Expand Down Expand Up @@ -52,6 +53,10 @@ function cornerstoneStreamingImageVolumeLoader(
const indexesToPrefetch = [0, middleImageIndex, lastImageIndex];
await Promise.all(
indexesToPrefetch.map((index) => {
// check if image is cached
if (cache.isLoaded(options.imageIds[index])) {
return Promise.resolve(true);
}
return new Promise((resolve, reject) => {
const imageId = options.imageIds[index];
imageLoadPoolManager.addRequest(
Expand Down

0 comments on commit 4f05843

Please # to comment.