mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-21 09:55:27 +10:00
fix: improve message sending logic and handle range download errors in translation service
This commit is contained in:
@@ -317,8 +317,12 @@ class TranslationService extends ChangeNotifier {
|
||||
final request = http.Request('GET', uri);
|
||||
request.headers['Range'] = 'bytes=$start-$end';
|
||||
final response = await client.send(request);
|
||||
if (response.statusCode != 206 && response.statusCode != 200) {
|
||||
throw StateError('Range download failed: HTTP ${response.statusCode}');
|
||||
if (response.statusCode != 206) {
|
||||
await response.stream.drain<void>();
|
||||
throw StateError(
|
||||
'Range download failed: HTTP ${response.statusCode}'
|
||||
'${response.statusCode == 200 ? ' (server ignored Range header)' : ''}',
|
||||
);
|
||||
}
|
||||
final trackedStream = _trackDownloadProgress(response.stream);
|
||||
await _fileStore.writeModelBytes(
|
||||
|
||||
Reference in New Issue
Block a user