Restrict GitHub sync provider to explicit developer export

This commit is contained in:
bponders12-cell 2026-09-01 20:45:18 -04:00
parent 10a435ebad
commit 7dfa294a80
1 changed files with 9 additions and 11 deletions

View File

@ -3,8 +3,8 @@ import '../github/github_sync_service.dart';
import 'sync_models.dart'; import 'sync_models.dart';
import 'sync_provider.dart'; import 'sync_provider.dart';
/// GitHub Synchronization Provider implementing Phase 2A SyncProvider. /// Explicit developer/export provider for the historical GitHub ride-log
/// Wraps existing GitHubSyncService cleanly without modifying its internal logic. /// exporter. MotorCloud is the only default/normal cloud backup destination.
class GitHubSyncProvider implements SyncProvider { class GitHubSyncProvider implements SyncProvider {
final GitHubSyncService service; final GitHubSyncService service;
final GitHubAuthService auth; final GitHubAuthService auth;
@ -18,25 +18,23 @@ class GitHubSyncProvider implements SyncProvider {
String get providerId => 'github'; String get providerId => 'github';
@override @override
Future<bool> isAvailable() async { Future<bool> isAvailable() async => auth.getToken() != null;
return auth.getToken() != null;
}
@override @override
Future<bool> requiresAuthentication() async { Future<bool> requiresAuthentication() async => auth.getToken() == null;
return auth.getToken() == null;
}
@override @override
Future<SyncResult> uploadRide(SyncItem item) async { Future<SyncResult> uploadRide(SyncItem item) async {
final hasAuth = auth.getToken() != null; final hasAuth = auth.getToken() != null;
if (!hasAuth) { if (!hasAuth) {
return SyncResult.authRequired( 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) { if (result.success) {
return SyncResult.success( return SyncResult.success(
@ -49,6 +47,6 @@ class GitHubSyncProvider implements SyncProvider {
return SyncResult.authRequired(message: result.message); return SyncResult.authRequired(message: result.message);
} }
return SyncResult.temporaryFailure(result.message); return SyncResult.permanentFailure(result.message);
} }
} }