fix: reset sqlite on beta migration (#20735)

reset sync stream on migration

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2025-09-15 03:00:25 +05:30 committed by GitHub
parent 15f182902f
commit dcee34095b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 54 additions and 31 deletions

View file

@ -3,7 +3,9 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:immich_mobile/constants/constants.dart';
import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/domain/models/sync_event.model.dart';
import 'package:immich_mobile/entities/store.entity.dart';
import 'package:immich_mobile/services/api.service.dart';
import 'package:logging/logging.dart';
import 'package:openapi/api.dart';
@ -33,6 +35,7 @@ class SyncApiRepository {
await _api.applyToParams([], headerParams);
headers.addAll(headerParams);
final shouldReset = Store.get(StoreKey.shouldResetSync, false);
final request = http.Request('POST', Uri.parse(endpoint));
request.headers.addAll(headers);
request.body = jsonEncode(
@ -58,6 +61,7 @@ class SyncApiRepository {
SyncRequestType.peopleV1,
SyncRequestType.assetFacesV1,
],
reset: shouldReset,
).toJson(),
);
@ -81,6 +85,9 @@ class SyncApiRepository {
throw ApiException(response.statusCode, 'Failed to get sync stream: $errorBody');
}
// Reset after successful stream start
await Store.put(StoreKey.shouldResetSync, false);
await for (final chunk in response.stream.transform(utf8.decoder)) {
if (shouldAbort) {
break;