Files
GitJournal/lib/sync_attempt.dart
Vishesh Handa 64b61b04dd SyncAttempt: Add the hash
It's not fully implemented but I rather just commit this right now.
2021-11-15 12:39:12 +01:00

40 lines
827 B
Dart

/*
* SPDX-FileCopyrightText: 2021 Vishesh Handa <me@vhanda.in>
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import 'package:dart_git/plumbing/git_hash.dart';
enum SyncStatus {
Unknown,
Done,
Pulling,
Merging,
Pushing,
Error,
}
class SyncAttemptPart {
final SyncStatus status;
final DateTime when;
final Exception? exception;
/// The headHash before the SyncStatus was started
final GitHash? headHash;
SyncAttemptPart(this.status, this.headHash, [this.exception])
: when = DateTime.now();
}
class SyncAttempt {
var parts = <SyncAttemptPart>[];
void add(SyncStatus status, [Exception? exception]) {
var part = SyncAttemptPart(status, GitHash.zero(), exception);
parts.add(part);
}
SyncStatus get status => parts.last.status;
DateTime get when => parts.last.when;
}