fixed client-reported crashes in the pdf viewer, image picker and prosemirror images, mapped webdav errors to user messages and hardened keychain, cache and push stores against io failures

This commit is contained in:
MineTec committed 2026-10-12 17:00:14 +02:00
1 parent c5592f117b
commit 23e4510bf8
19 files changed
+545 -55

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
import 'package:flutter/services.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
/// `errSecDuplicateItem`: the iOS keychain refused to add an item that is
/// already there.
const int kErrSecDuplicateItem = -25299;
/// Whether [error] is the iOS keychain's "item already exists" failure.
/// flutter_secure_storage surfaces it as a PlatformException whose details
/// (and message) carry the OSStatus.
bool isKeychainDuplicateItem(Object error) {
if (error is! PlatformException) return false;
if (error.details == kErrSecDuplicateItem) return true;
return error.message?.contains('$kErrSecDuplicateItem') ?? false;
}
extension KeychainWrite on FlutterSecureStorage {
/// [write] that survives `errSecDuplicateItem`. The plugin's iOS write is
/// check-then-add/update and not atomic: a concurrent write to the same key
/// — or an existence check that itself failed (seen with the disk full) —
/// ends in SecItemAdd on an existing item. The second attempt finds the
/// item and updates it.
Future<void> writeRetrying({
required String key,
required String value,
}) async {
try {
await write(key: key, value: value);
} on PlatformException catch (e) {
if (!isKeychainDuplicateItem(e)) rethrow;
await write(key: key, value: value);
}
}
}