Skip to content

Commit 2209d03

Browse files
committed
legacy-data: Tolerate an item failing to decompress
I believe the legacy app never actually leaves behind data that would trigger this. But if it does, avoid throwing an exception.
1 parent c750bdc commit 2209d03

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/model/legacy_app_data.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,13 @@ class LegacyAppDatabase {
272272
// Not sure how newlines get there into the data; but empirically
273273
// they do, after each 76 characters of `encodedSplit`.
274274
final encoded = encodedSplit.replaceAll('\n', '');
275-
final compressedBytes = base64Decode(encoded);
276-
final uncompressedBytes = zlib.decoder.convert(compressedBytes);
277-
return utf8.decode(uncompressedBytes);
275+
try {
276+
final compressedBytes = base64Decode(encoded);
277+
final uncompressedBytes = zlib.decoder.convert(compressedBytes);
278+
return utf8.decode(uncompressedBytes);
279+
} catch (_) {
280+
return null; // TODO(log)
281+
}
278282
}
279283
return item;
280284
}

0 commit comments

Comments
 (0)