preload static method

Future<void> preload()

Preload common directories into cache. Call this after login to make file browser feel instant.

Implementation

static Future<void> preload() async {
  try {
    // Check if already cached.
    if (_cache.containsKey('') && _cache.containsKey('data')) {
      debugPrint('PodDirectoryService.preload: skipped (cache exists)');
      return;
    }

    debugPrint('PodDirectoryService.preload: starting...');

    // Preload root directory and data directory in parallel.
    await Future.wait([
      listDirectory(''), // geopod/
      listDirectory('data'), // geopod/data/
      listDirectory('data/places'), // geopod/data/places/
    ]);

    debugPrint('PodDirectoryService.preload: completed');
  } catch (e) {
    debugPrint('PodDirectoryService.preload: error $e');
  }
}