react-native-fast-image 9.3.2 → 9.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -280,6 +280,11 @@ class FastImageViewModule extends ReactContextBaseJavaModule {
280
280
  .asFile()
281
281
  .load(model)
282
282
  .apply(options)
283
+ // Not kept in or taken from the memory cache (asFile() skips
284
+ // it, but the options turn it back on): the file is only there
285
+ // while the disk cache keeps it, and Glide gave the path of
286
+ // one that clearDiskCache had deleted.
287
+ .skipMemoryCache(true)
283
288
  .listener(new RequestListener<File>() {
284
289
  @Override
285
290
  public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<File> target, boolean isFirstResource) {
@@ -307,6 +312,8 @@ class FastImageViewModule extends ReactContextBaseJavaModule {
307
312
  .asFile()
308
313
  .load(model)
309
314
  .apply(options)
315
+ // On disk only, as in loadFile.
316
+ .skipMemoryCache(true)
310
317
  .onlyRetrieveFromCache(true)
311
318
  .submit()
312
319
  .get();
@@ -322,8 +329,10 @@ class FastImageViewModule extends ReactContextBaseJavaModule {
322
329
  return result;
323
330
  }
324
331
 
325
- // Where getCachePath looks in the caches and downloads `web` images
326
- // (blocking calls, off the UI and modules threads).
332
+ // Where getCachePath looks in the caches and downloads `web` images,
333
+ // writeToCache stores files, configureCache measures the disk cache and
334
+ // clearDiskCache empties it (blocking calls, off the UI and modules
335
+ // threads).
327
336
  private static final Executor cachePathExecutor = Executors.newSingleThreadExecutor();
328
337
 
329
338
  private static WritableMap pathResult(File file) {
@@ -590,24 +599,33 @@ class FastImageViewModule extends ReactContextBaseJavaModule {
590
599
  });
591
600
  }
592
601
 
593
- // On the native modules' thread: Glide clears its disk cache off the main
594
- // thread.
602
+ // On cachePathExecutor: Glide clears its disk cache off the main thread,
603
+ // and the native modules' thread runs every module's async methods (e.g.
604
+ // a fetch()'s request), which would wait for it. It's also in order with
605
+ // the disk work of getCachePath, writeToCache and configureCache there.
595
606
  @ReactMethod
596
- public void clearDiskCache(Promise promise) {
597
- try {
598
- FastImageGlide.getRegistered(getReactApplicationContext()).clearDiskCache();
599
- } catch (RuntimeException e) {
600
- promise.resolve(failure(e));
601
- return;
602
- }
603
- // And the HTTP cache of `cache: 'web'` images, which Glide doesn't
604
- // cache (set up when FastImage's components are registered).
605
- try {
606
- FastImageOkHttpProgressGlideModule.clearWebCache();
607
- } catch (IOException e) {
608
- // Cleared as far as it could.
609
- }
610
- promise.resolve(cleared());
607
+ public void clearDiskCache(final Promise promise) {
608
+ final ReactApplicationContext context = getReactApplicationContext();
609
+ cachePathExecutor.execute(new Runnable() {
610
+ @Override
611
+ public void run() {
612
+ try {
613
+ FastImageGlide.getRegistered(context).clearDiskCache();
614
+ } catch (RuntimeException e) {
615
+ promise.resolve(failure(e));
616
+ return;
617
+ }
618
+ // And the HTTP cache of `cache: 'web'` images, which Glide
619
+ // doesn't cache (set up when FastImage's components are
620
+ // registered).
621
+ try {
622
+ FastImageOkHttpProgressGlideModule.clearWebCache();
623
+ } catch (IOException e) {
624
+ // Cleared as far as it could.
625
+ }
626
+ promise.resolve(cleared());
627
+ }
628
+ });
611
629
  }
612
630
 
613
631
  private static WritableMap cleared() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-fast-image",
3
- "version": "9.3.2",
3
+ "version": "9.3.3",
4
4
  "description": "FastImage, performant React Native image component.",
5
5
  "keywords": [
6
6
  "cache",