mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 23:05:19 +00:00
Invalidate media deletion callbacks during panic
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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?() },
|
||||
|
||||
Reference in New Issue
Block a user