Fix background polling crash
This commit is contained in:
parent
f526475f2f
commit
86c2c39425
|
@ -59,7 +59,9 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject
|
|||
|
||||
// MARK: Running
|
||||
public func execute() {
|
||||
JobQueue.currentlyExecutingJobs.insert(id!)
|
||||
if let id = id {
|
||||
JobQueue.currentlyExecutingJobs.insert(id)
|
||||
}
|
||||
guard !isDeferred else { return }
|
||||
if TSAttachment.fetch(uniqueId: attachmentID) is TSAttachmentStream {
|
||||
// FIXME: It's not clear * how * this happens, but apparently we can get to this point
|
||||
|
|
|
@ -60,7 +60,9 @@ public final class AttachmentUploadJob : NSObject, Job, NSCoding { // NSObject/N
|
|||
|
||||
// MARK: Running
|
||||
public func execute() {
|
||||
JobQueue.currentlyExecutingJobs.insert(id!)
|
||||
if let id = id {
|
||||
JobQueue.currentlyExecutingJobs.insert(id)
|
||||
}
|
||||
guard let stream = TSAttachment.fetch(uniqueId: attachmentID) as? TSAttachmentStream else {
|
||||
return handleFailure(error: Error.noAttachment)
|
||||
}
|
||||
|
|
|
@ -54,7 +54,9 @@ public final class MessageReceiveJob : NSObject, Job, NSCoding { // NSObject/NSC
|
|||
}
|
||||
|
||||
public func execute() -> Promise<Void> {
|
||||
JobQueue.currentlyExecutingJobs.insert(id!)
|
||||
if let id = id { // Can be nil (e.g. when background polling)
|
||||
JobQueue.currentlyExecutingJobs.insert(id)
|
||||
}
|
||||
let (promise, seal) = Promise<Void>.pending()
|
||||
SNMessagingKitConfiguration.shared.storage.write(with: { transaction in // Intentionally capture self
|
||||
do {
|
||||
|
|
|
@ -69,7 +69,9 @@ public final class MessageSendJob : NSObject, Job, NSCoding { // NSObject/NSCodi
|
|||
|
||||
// MARK: Running
|
||||
public func execute() {
|
||||
JobQueue.currentlyExecutingJobs.insert(id!)
|
||||
if let id = id {
|
||||
JobQueue.currentlyExecutingJobs.insert(id)
|
||||
}
|
||||
let storage = SNMessagingKitConfiguration.shared.storage
|
||||
if let message = message as? VisibleMessage {
|
||||
guard TSOutgoingMessage.find(withTimestamp: message.sentTimestamp!) != nil else { return } // The message has been deleted
|
||||
|
|
|
@ -38,7 +38,9 @@ public final class NotifyPNServerJob : NSObject, Job, NSCoding { // NSObject/NSC
|
|||
}
|
||||
|
||||
public func execute() -> Promise<Void> {
|
||||
JobQueue.currentlyExecutingJobs.insert(id!)
|
||||
if let id = id {
|
||||
JobQueue.currentlyExecutingJobs.insert(id)
|
||||
}
|
||||
let server = PushNotificationAPI.server
|
||||
let parameters = [ "data" : message.data.description, "send_to" : message.recipient ]
|
||||
let url = URL(string: "\(server)/notify")!
|
||||
|
|
Loading…
Reference in New Issue