Invalidate media deletion callbacks during panic

This commit is contained in:
jack
2026-07-25 20:43:07 +02:00
parent 62e9a1d83d
commit 4bd6e3d445
8 changed files with 236 additions and 10 deletions
@@ -179,10 +179,21 @@ struct BLEIncomingFileStore: @unchecked Sendable {
func panicWipe(
hasDurablePendingMarker: Bool = false
) throws {
// The receipt index caches tombstones as well as accepted payloads.
// Always invalidate it on return, including partial-failure paths, so
// no pre-panic receiver decision survives after identity reset.
defer { privateMediaReceipts.resetForPanic() }
// The receipt index caches tombstones as well as accepted payloads,
// while payload coordination retains save/delete reservations. Always
// invalidate both on return, including partial-failure paths, so no
// pre-panic receiver decision survives after identity reset.
defer {
privateMediaReceipts.resetForPanic()
payloadCoordination.lock.lock()
payloadCoordination.pendingDeliveryPaths.removeAll(
keepingCapacity: false
)
payloadCoordination.deletionReservations.removeAll(
keepingCapacity: false
)
payloadCoordination.lock.unlock()
}
let markerError: Error?
do {
+28 -3
View File
@@ -3492,6 +3492,18 @@ extension BLEService {
}
}
func _test_emitTransportEvent(
_ event: TransportEvent,
completion: @escaping () -> Void,
finalization: @escaping (TransportEventDeliveryOutcome) -> Void
) {
emitTransportEvent(
event,
completion: completion,
finalization: finalization
)
}
func _test_handlePacket(_ packet: BitchatPacket, fromPeerID: PeerID, preseedPeer: Bool = true, signingPublicKey: Data? = nil) {
if preseedPeer {
// Ensure the synthetic peer is known and marked verified for public-message tests
@@ -4504,11 +4516,24 @@ extension BLEService {
completion: (() -> Void)? = nil,
finalization: ((TransportEventDeliveryOutcome) -> Void)? = nil
) {
notifyUI { [weak self] in
guard let generation = capturePanicLifecycleGeneration() else {
Task { @MainActor in
finalization?(.rejected)
}
return
}
Task { @MainActor [weak self] in
guard let self,
self.isCurrentPanicLifecycleGeneration(generation) else {
finalization?(.rejected)
return
}
TransportEventDeliveryGate.attempt(
shouldDeliver: { shouldDeliver?() ?? true },
shouldDeliver: {
self.isCurrentPanicLifecycleGeneration(generation)
&& (shouldDeliver?() ?? true)
},
deliver: {
guard let self else { return .rejected }
return self.deliverTransportEvent(event)
},
completion: { completion?() },