getSize method

int getSize()
inherited

Size of this store's on-disk footprint, in KB. Sums the lengths of every file under storagePath whose name starts with the box name (Hive writes <boxName>.hive and <boxName>.lock). The previous impl summed the WHOLE storagePath directory, which double-counts whenever multiple boxes share a directory (which they do on the secondary).

Implementation

int getSize() {
  final dir = Directory(storagePath);
  if (!dir.existsSync()) return 0;
  var bytes = 0;
  for (final entity in dir.listSync()) {
    if (entity is! File) continue;
    final name = entity.uri.pathSegments.last;
    if (!name.startsWith('$_boxName.')) continue;
    bytes += entity.lengthSync();
  }
  return bytes ~/ 1024;
}