Restrict GitHub sync provider to explicit developer export
This commit is contained in:
parent
10a435ebad
commit
7dfa294a80
|
|
@ -3,8 +3,8 @@ import '../github/github_sync_service.dart';
|
|||
import 'sync_models.dart';
|
||||
import 'sync_provider.dart';
|
||||
|
||||
/// GitHub Synchronization Provider implementing Phase 2A SyncProvider.
|
||||
/// Wraps existing GitHubSyncService cleanly without modifying its internal logic.
|
||||
/// Explicit developer/export provider for the historical GitHub ride-log
|
||||
/// exporter. MotorCloud is the only default/normal cloud backup destination.
|
||||
class GitHubSyncProvider implements SyncProvider {
|
||||
final GitHubSyncService service;
|
||||
final GitHubAuthService auth;
|
||||
|
|
@ -18,25 +18,23 @@ class GitHubSyncProvider implements SyncProvider {
|
|||
String get providerId => 'github';
|
||||
|
||||
@override
|
||||
Future<bool> isAvailable() async {
|
||||
return auth.getToken() != null;
|
||||
}
|
||||
Future<bool> isAvailable() async => auth.getToken() != null;
|
||||
|
||||
@override
|
||||
Future<bool> requiresAuthentication() async {
|
||||
return auth.getToken() == null;
|
||||
}
|
||||
Future<bool> requiresAuthentication() async => auth.getToken() == null;
|
||||
|
||||
@override
|
||||
Future<SyncResult> uploadRide(SyncItem item) async {
|
||||
final hasAuth = auth.getToken() != null;
|
||||
if (!hasAuth) {
|
||||
return SyncResult.authRequired(
|
||||
message: 'GitHub Personal Access Token (PAT) required for synchronization.',
|
||||
message: 'GitHub developer export requires an explicitly configured GitHub token.',
|
||||
);
|
||||
}
|
||||
|
||||
final result = await service.uploadRide(item.localRideId);
|
||||
// This provider is intentionally the only path that may call the legacy
|
||||
// GitHub exporter. Normal History -> Upload Now uses Firebase/MotorCloud.
|
||||
final result = await service.uploadRideToGitHub(item.localRideId);
|
||||
|
||||
if (result.success) {
|
||||
return SyncResult.success(
|
||||
|
|
@ -49,6 +47,6 @@ class GitHubSyncProvider implements SyncProvider {
|
|||
return SyncResult.authRequired(message: result.message);
|
||||
}
|
||||
|
||||
return SyncResult.temporaryFailure(result.message);
|
||||
return SyncResult.permanentFailure(result.message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue