readWorkerState static method

({String? step, int targetsDone})? readWorkerState(
  1. String path
)

Reads the step and completed targets a worker process reported.

Implementation

static ({String? step, int targetsDone})? readWorkerState(String path) {
  try {
    final json =
        jsonDecode(File(path).readAsStringSync()) as Map<String, dynamic>;
    final job = (json['jobs'] as List).first as Map<String, dynamic>;
    return (
      step: job['step'] as String?,
      targetsDone: job['targetsDone'] as int? ?? 0
    );
  } catch (_) {
    return null;
  }
}