hash method

SyncRef hash()
override

Deterministic SHA-256 over "<path>\0<size>\0<hash>\n" lines in sorted path order. Excludes mtime so the result is reproducible.

Implementation

SyncRef hash() {
  final buffer = StringBuffer();
  for (final path in sortedPaths) {
    final e = entries[path]!;
    buffer.write('$path${e.size}${e.hash.value}\n');
  }
  final digest = sha256.convert(utf8.encode(buffer.toString()));
  return SyncRef.directory(digest.toString());
}