clearParentCache method

Future<void> clearParentCache(
  1. String itemUuid,
  2. String itemType,
  3. FilenApi api,
  4. FilenCrypto crypto,
  5. List<String> masterKeys,
)

Implementation

Future<void> clearParentCache(String itemUuid, String itemType, FilenApi api,
    FilenCrypto crypto, List<String> masterKeys) async {
  try {
    String? parentUuid;

    if (itemType == 'file') {
      final info = await api.post('/v3/file', {'uuid': itemUuid});
      parentUuid = info['data']?['parent'];
    } else if (itemType == 'folder') {
      final info = await api.post('/v3/dir', {'uuid': itemUuid});
      parentUuid = info['data']?['parent'];
    }

    if (parentUuid != null) {
      invalidate(parentUuid);
      api.log('Cleared parent cache for $parentUuid');
    }
  } catch (e) {
    api.log('Could not clear parent cache for $itemUuid: $e');
  }
}