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,
|
int batchSize = kSyncEventBatchSize,
|
||||||
http.Client? httpClient,
|
http.Client? httpClient,
|
||||||
}) async {
|
}) async {
|
||||||
// ignore: avoid-unused-assignment
|
|
||||||
final stopwatch = Stopwatch()..start();
|
final stopwatch = Stopwatch()..start();
|
||||||
final client = httpClient ?? http.Client();
|
final client = httpClient ?? http.Client();
|
||||||
final endpoint = "${_api.apiClient.basePath}/sync/stream";
|
final endpoint = "${_api.apiClient.basePath}/sync/stream";
|
||||||
@ -98,7 +97,7 @@ class SyncApiRepository implements ISyncApiRepository {
|
|||||||
await onData(_parseLines(lines), abort);
|
await onData(_parseLines(lines), abort);
|
||||||
}
|
}
|
||||||
} catch (error, stack) {
|
} catch (error, stack) {
|
||||||
_logger.severe("error processing stream", error, stack);
|
_logger.severe("Error processing stream", error, stack);
|
||||||
return Future.error(error, stack);
|
return Future.error(error, stack);
|
||||||
} finally {
|
} finally {
|
||||||
client.close();
|
client.close();
|
||||||
@ -112,21 +111,17 @@ class SyncApiRepository implements ISyncApiRepository {
|
|||||||
final List<SyncEvent> data = [];
|
final List<SyncEvent> data = [];
|
||||||
|
|
||||||
for (final line in lines) {
|
for (final line in lines) {
|
||||||
try {
|
final jsonData = jsonDecode(line);
|
||||||
final jsonData = jsonDecode(line);
|
final type = SyncEntityType.fromJson(jsonData['type'])!;
|
||||||
final type = SyncEntityType.fromJson(jsonData['type'])!;
|
final dataJson = jsonData['data'];
|
||||||
final dataJson = jsonData['data'];
|
final ack = jsonData['ack'];
|
||||||
final ack = jsonData['ack'];
|
final converter = _kResponseMap[type];
|
||||||
final converter = _kResponseMap[type];
|
if (converter == null) {
|
||||||
if (converter == null) {
|
_logger.warning("Unknown type $type");
|
||||||
_logger.warning("[_parseSyncResponse] Unknown type $type");
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.add(SyncEvent(type: type, data: converter(dataJson), ack: ack));
|
|
||||||
} catch (error, stack) {
|
|
||||||
_logger.severe("[_parseSyncResponse] Error parsing json", error, stack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.add(SyncEvent(type: type, data: converter(dataJson), ack: ack));
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user