read method

Future<String?> read(
  1. String checksum
)

Returns the path at the provided checksum stored in the database.

Implementation

Future<String?> read(String checksum) async {
  final String? existing = _cache[checksum];
  if (existing != null) {
    return existing;
  }

  return await safe<String?>((db) async {
    final stmt = db.select(db.downloads)
      ..where((u) => u.checksum.equals(checksum));
    final DownloadRow? row = await stmt.getSingleOrNull();
    return row?.path;
  }, exclusive: false);
}