sync method

Future<SyncOutcome> sync(
  1. String mountId, {
  2. SyncDirection? direction,
  3. DriveProgress? onProgress,
})

Synchronizes mountId. With no direction, picks one automatically: read-only mounts always push; read-write mounts push, pull or no-op based on which side changed (a two-sided change surfaces a conflict).

Implementation

Future<SyncOutcome> sync(
  String mountId, {
  SyncDirection? direction,
  DriveProgress? onProgress,
}) async {
  final record = require(mountId);
  final outcome = await _withSession(record, (rpc) async {
    if (record.isGit) {
      return _syncGit(record, rpc, direction, onProgress: onProgress);
    }
    final dir = direction ?? await _autoDirection(record, rpc);
    if (dir == null) {
      return SyncOutcome(record: record); // already clean
    }
    return _syncDirectory(record, rpc, dir, onProgress: onProgress);
  });
  store.mounts[mountId] = outcome.record;
  await store.save();
  return outcome;
}