mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
fix(mobile): do not continue on remote stream parse error (#18344)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
86db0aafe5
commit
9771e48049
@ -25,7 +25,6 @@ class SyncApiRepository implements ISyncApiRepository {
|
||||
int batchSize = kSyncEventBatchSize,
|
||||
http.Client? httpClient,
|
||||
}) async {
|
||||
// ignore: avoid-unused-assignment
|
||||
final stopwatch = Stopwatch()..start();
|
||||
final client = httpClient ?? http.Client();
|
||||
final endpoint = "${_api.apiClient.basePath}/sync/stream";
|
||||
@ -98,7 +97,7 @@ class SyncApiRepository implements ISyncApiRepository {
|
||||
await onData(_parseLines(lines), abort);
|
||||
}
|
||||
} catch (error, stack) {
|
||||
_logger.severe("error processing stream", error, stack);
|
||||
_logger.severe("Error processing stream", error, stack);
|
||||
return Future.error(error, stack);
|
||||
} finally {
|
||||
client.close();
|
||||
@ -112,21 +111,17 @@ class SyncApiRepository implements ISyncApiRepository {
|
||||
final List<SyncEvent> data = [];
|
||||
|
||||
for (final line in lines) {
|
||||
try {
|
||||
final jsonData = jsonDecode(line);
|
||||
final type = SyncEntityType.fromJson(jsonData['type'])!;
|
||||
final dataJson = jsonData['data'];
|
||||
final ack = jsonData['ack'];
|
||||
final converter = _kResponseMap[type];
|
||||
if (converter == null) {
|
||||
_logger.warning("[_parseSyncResponse] Unknown type $type");
|
||||
_logger.warning("Unknown type $type");
|
||||
continue;
|
||||
}
|
||||
|
||||
data.add(SyncEvent(type: type, data: converter(dataJson), ack: ack));
|
||||
} catch (error, stack) {
|
||||
_logger.severe("[_parseSyncResponse] Error parsing json", error, stack);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user