Make uniqueId non-nil (generated changes).
This commit is contained in:
parent
1e363d2c65
commit
a7faef647b
@ -144,14 +144,9 @@ public extension OWSContactQuery {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if OWSContactQuery.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if OWSContactQuery.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -182,10 +177,6 @@ public extension OWSContactQuery {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (OWSContactQuery) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -205,26 +196,7 @@ public extension OWSContactQuery {
|
||||
}
|
||||
|
||||
func anyRemove(transaction: SDSAnyWriteTransaction) {
|
||||
guard shouldBeSaved else {
|
||||
// Skipping remove.
|
||||
return
|
||||
}
|
||||
|
||||
anyWillRemove(with: transaction)
|
||||
|
||||
switch transaction.writeTransaction {
|
||||
case .yapWrite(let ydbTransaction):
|
||||
ydb_remove(with: ydbTransaction)
|
||||
case .grdbWrite(let grdbTransaction):
|
||||
do {
|
||||
let record = try asRecord()
|
||||
record.sdsRemove(transaction: grdbTransaction)
|
||||
} catch {
|
||||
owsFail("Remove failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
anyDidRemove(with: transaction)
|
||||
sdsRemove(transaction: transaction)
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction) {
|
||||
@ -232,11 +204,6 @@ public extension OWSContactQuery {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -340,7 +307,7 @@ public extension OWSContactQuery {
|
||||
break
|
||||
}
|
||||
}
|
||||
} catch let error as NSError {
|
||||
} catch let error {
|
||||
owsFailDebug("Couldn't fetch models: \(error)")
|
||||
}
|
||||
}
|
||||
@ -405,12 +372,20 @@ public extension OWSContactQuery {
|
||||
owsFailDebug("deleteAll() failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
if shouldBeIndexedForFTS {
|
||||
FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction)
|
||||
}
|
||||
}
|
||||
|
||||
class func anyRemoveAllWithInstantation(transaction: SDSAnyWriteTransaction) {
|
||||
anyEnumerate(transaction: transaction) { (instance, _) in
|
||||
instance.anyRemove(transaction: transaction)
|
||||
}
|
||||
|
||||
if shouldBeIndexedForFTS {
|
||||
FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -475,10 +450,7 @@ class OWSContactQuerySerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .contactQuery
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let lastQueried: Date = model.lastQueried
|
||||
|
||||
@ -144,14 +144,9 @@ public extension OWSDisappearingMessagesConfiguration {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if OWSDisappearingMessagesConfiguration.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if OWSDisappearingMessagesConfiguration.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -182,10 +177,6 @@ public extension OWSDisappearingMessagesConfiguration {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (OWSDisappearingMessagesConfiguration) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -232,11 +223,6 @@ public extension OWSDisappearingMessagesConfiguration {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -475,10 +461,7 @@ class OWSDisappearingMessagesConfigurationSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .disappearingMessagesConfiguration
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let durationSeconds: UInt32 = model.durationSeconds
|
||||
|
||||
@ -169,14 +169,9 @@ public extension SignalAccount {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if SignalAccount.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if SignalAccount.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -207,10 +202,6 @@ public extension SignalAccount {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (SignalAccount) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -257,11 +248,6 @@ public extension SignalAccount {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -500,10 +486,7 @@ class SignalAccountSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .signalAccount
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let accountSchemaVersion: UInt = model.accountSchemaVersion
|
||||
|
||||
@ -157,14 +157,9 @@ public extension SignalRecipient {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if SignalRecipient.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if SignalRecipient.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -195,10 +190,6 @@ public extension SignalRecipient {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (SignalRecipient) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -245,11 +236,6 @@ public extension SignalRecipient {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -488,10 +474,7 @@ class SignalRecipientSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .signalRecipient
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let devices: Data = requiredArchive(model.devices)
|
||||
|
||||
@ -58,10 +58,7 @@ class TSContactThreadSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .contactThread
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let archivalDate: Date? = model.archivalDate
|
||||
|
||||
@ -58,10 +58,7 @@ class TSGroupThreadSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .groupThread
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let archivalDate: Date? = model.archivalDate
|
||||
|
||||
@ -156,14 +156,9 @@ public extension OWSDevice {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if OWSDevice.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if OWSDevice.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -194,10 +189,6 @@ public extension OWSDevice {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (OWSDevice) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -244,11 +235,6 @@ public extension OWSDevice {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -487,10 +473,7 @@ class OWSDeviceSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .device
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let createdAt: Date = model.createdAt
|
||||
|
||||
@ -162,14 +162,9 @@ public extension OWSLinkedDeviceReadReceipt {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if OWSLinkedDeviceReadReceipt.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if OWSLinkedDeviceReadReceipt.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -200,10 +195,6 @@ public extension OWSLinkedDeviceReadReceipt {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (OWSLinkedDeviceReadReceipt) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -250,11 +241,6 @@ public extension OWSLinkedDeviceReadReceipt {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -493,10 +479,7 @@ class OWSLinkedDeviceReadReceiptSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .linkedDeviceReadReceipt
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let linkedDeviceReadReceiptSchemaVersion: UInt = model.linkedDeviceReadReceiptSchemaVersion
|
||||
|
||||
@ -349,14 +349,9 @@ public extension TSAttachment {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if TSAttachment.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if TSAttachment.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -387,10 +382,6 @@ public extension TSAttachment {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (TSAttachment) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -437,11 +428,6 @@ public extension TSAttachment {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -680,10 +666,7 @@ class TSAttachmentSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .attachment
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let albumMessageId: String? = model.albumMessageId
|
||||
|
||||
@ -58,10 +58,7 @@ class TSAttachmentPointerSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .attachmentPointer
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let albumMessageId: String? = model.albumMessageId
|
||||
|
||||
@ -58,10 +58,7 @@ class TSAttachmentStreamSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .attachmentStream
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let albumMessageId: String? = model.albumMessageId
|
||||
|
||||
@ -58,10 +58,7 @@ class OWSDisappearingConfigurationUpdateInfoMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .disappearingConfigurationUpdateInfoMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class OWSVerificationStateChangeMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .verificationStateChangeMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class TSErrorMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .errorMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class TSIncomingMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .incomingMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class TSInfoMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .infoMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -1309,14 +1309,9 @@ public extension TSInteraction {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if TSInteraction.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if TSInteraction.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -1347,10 +1342,6 @@ public extension TSInteraction {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (TSInteraction) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -1397,11 +1388,6 @@ public extension TSInteraction {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -1640,10 +1626,7 @@ class TSInteractionSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .interaction
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class TSMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .message
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class TSOutgoingMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .outgoingMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class TSUnreadIndicatorInteractionSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .unreadIndicatorInteraction
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class TSInvalidIdentityKeyErrorMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .invalidIdentityKeyErrorMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class TSInvalidIdentityKeyReceivingErrorMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .invalidIdentityKeyReceivingErrorMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class TSInvalidIdentityKeySendingErrorMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .invalidIdentityKeySendingErrorMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class OWSAddToContactsOfferMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .addToContactsOfferMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class OWSAddToProfileWhitelistOfferMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .addToProfileWhitelistOfferMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -156,14 +156,9 @@ public extension OWSMessageContentJob {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if OWSMessageContentJob.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if OWSMessageContentJob.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -194,10 +189,6 @@ public extension OWSMessageContentJob {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (OWSMessageContentJob) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -244,11 +235,6 @@ public extension OWSMessageContentJob {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -487,10 +473,7 @@ class OWSMessageContentJobSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .messageContentJob
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let createdAt: Date = model.createdAt
|
||||
|
||||
@ -144,14 +144,9 @@ public extension OWSMessageDecryptJob {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if OWSMessageDecryptJob.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if OWSMessageDecryptJob.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -182,10 +177,6 @@ public extension OWSMessageDecryptJob {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (OWSMessageDecryptJob) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -232,11 +223,6 @@ public extension OWSMessageDecryptJob {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -475,10 +461,7 @@ class OWSMessageDecryptJobSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .messageDecryptJob
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let createdAt: Date = model.createdAt
|
||||
|
||||
@ -151,14 +151,9 @@ public extension TSRecipientReadReceipt {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if TSRecipientReadReceipt.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if TSRecipientReadReceipt.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -189,10 +184,6 @@ public extension TSRecipientReadReceipt {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (TSRecipientReadReceipt) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -239,11 +230,6 @@ public extension TSRecipientReadReceipt {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -482,10 +468,7 @@ class TSRecipientReadReceiptSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .recipientReadReceipt
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let recipientMap: Data = requiredArchive(model.recipientMap)
|
||||
|
||||
@ -58,10 +58,7 @@ class OWSUnknownContactBlockOfferMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .unknownContactBlockOfferMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class OWSUnknownProtocolVersionMessageSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .unknownProtocolVersionMessage
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -145,14 +145,9 @@ public extension InstalledSticker {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if InstalledSticker.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if InstalledSticker.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -183,10 +178,6 @@ public extension InstalledSticker {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (InstalledSticker) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -233,11 +224,6 @@ public extension InstalledSticker {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -476,10 +462,7 @@ class InstalledStickerSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .installedSticker
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let emojiString: String? = model.emojiString
|
||||
|
||||
@ -151,14 +151,9 @@ public extension KnownStickerPack {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if KnownStickerPack.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if KnownStickerPack.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -189,10 +184,6 @@ public extension KnownStickerPack {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (KnownStickerPack) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -239,11 +230,6 @@ public extension KnownStickerPack {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -482,10 +468,7 @@ class KnownStickerPackSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .knownStickerPack
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let dateCreated: Date = model.dateCreated
|
||||
|
||||
@ -177,14 +177,9 @@ public extension StickerPack {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if StickerPack.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if StickerPack.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -215,10 +210,6 @@ public extension StickerPack {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (StickerPack) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -265,11 +256,6 @@ public extension StickerPack {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -508,10 +494,7 @@ class StickerPackSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .stickerPack
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let author: String? = model.author
|
||||
|
||||
@ -58,10 +58,7 @@ class TSCallSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .call
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let receivedAtTimestamp: UInt64 = model.receivedAtTimestamp
|
||||
|
||||
@ -58,10 +58,7 @@ class SSKMessageDecryptJobRecordSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .messageDecryptJobRecord
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let failureCount: UInt = model.failureCount
|
||||
|
||||
@ -168,14 +168,9 @@ public extension OWSRecipientIdentity {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if OWSRecipientIdentity.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if OWSRecipientIdentity.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -206,10 +201,6 @@ public extension OWSRecipientIdentity {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (OWSRecipientIdentity) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -256,11 +247,6 @@ public extension OWSRecipientIdentity {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -499,10 +485,7 @@ class OWSRecipientIdentitySerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .recipientIdentity
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let accountId: String = model.accountId
|
||||
|
||||
@ -58,10 +58,7 @@ class OWSSessionResetJobRecordSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .sessionResetJobRecord
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let failureCount: UInt = model.failureCount
|
||||
|
||||
@ -243,14 +243,9 @@ public extension SSKJobRecord {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if SSKJobRecord.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if SSKJobRecord.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -281,10 +276,6 @@ public extension SSKJobRecord {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (SSKJobRecord) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -331,11 +322,6 @@ public extension SSKJobRecord {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -574,10 +560,7 @@ class SSKJobRecordSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .jobRecord
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let failureCount: UInt = model.failureCount
|
||||
|
||||
@ -58,10 +58,7 @@ class SSKMessageSenderJobRecordSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .messageSenderJobRecord
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let failureCount: UInt = model.failureCount
|
||||
|
||||
@ -129,14 +129,9 @@ public extension ExperienceUpgrade {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if ExperienceUpgrade.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if ExperienceUpgrade.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -167,10 +162,6 @@ public extension ExperienceUpgrade {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (ExperienceUpgrade) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -217,11 +208,6 @@ public extension ExperienceUpgrade {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -460,10 +446,7 @@ class ExperienceUpgradeSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .experienceUpgrade
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
return ExperienceUpgradeRecord(id: id, recordType: recordType, uniqueId: uniqueId)
|
||||
}
|
||||
|
||||
@ -168,14 +168,9 @@ public extension OWSBackupFragment {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if OWSBackupFragment.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if OWSBackupFragment.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -206,10 +201,6 @@ public extension OWSBackupFragment {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (OWSBackupFragment) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -256,11 +247,6 @@ public extension OWSBackupFragment {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -499,10 +485,7 @@ class OWSBackupFragmentSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .backupFragment
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let attachmentId: String? = model.attachmentId
|
||||
|
||||
@ -175,14 +175,9 @@ public extension OWSUserProfile {
|
||||
@available(*, deprecated, message: "Use anyInsert() or anyUpdate() instead.")
|
||||
func anyUpsert(transaction: SDSAnyWriteTransaction) {
|
||||
let isInserting: Bool
|
||||
if let uniqueId = uniqueId {
|
||||
if OWSUserProfile.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
isInserting = true
|
||||
}
|
||||
if OWSUserProfile.anyFetch(uniqueId: uniqueId, transaction: transaction) != nil {
|
||||
isInserting = false
|
||||
} else {
|
||||
owsFailDebug("Missing uniqueId: \(type(of: self))")
|
||||
isInserting = true
|
||||
}
|
||||
sdsSave(saveMode: isInserting ? .insert : .update, transaction: transaction)
|
||||
@ -213,10 +208,6 @@ public extension OWSUserProfile {
|
||||
// This isn't a perfect arrangement, but in practice this will prevent
|
||||
// data loss and will resolve all known issues.
|
||||
func anyUpdate(transaction: SDSAnyWriteTransaction, block: (OWSUserProfile) -> Void) {
|
||||
guard let uniqueId = uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
return
|
||||
}
|
||||
|
||||
block(self)
|
||||
|
||||
@ -263,11 +254,6 @@ public extension OWSUserProfile {
|
||||
}
|
||||
|
||||
func anyReload(transaction: SDSAnyReadTransaction, ignoreMissing: Bool) {
|
||||
guard let uniqueId = self.uniqueId else {
|
||||
owsFailDebug("uniqueId was unexpectedly nil")
|
||||
return
|
||||
}
|
||||
|
||||
guard let latestVersion = type(of: self).anyFetch(uniqueId: uniqueId, transaction: transaction) else {
|
||||
if !ignoreMissing {
|
||||
owsFailDebug("`latest` was unexpectedly nil")
|
||||
@ -506,10 +492,7 @@ class OWSUserProfileSerializer: SDSSerializer {
|
||||
let id: Int64? = nil
|
||||
|
||||
let recordType: SDSRecordType = .userProfile
|
||||
guard let uniqueId: String = model.uniqueId else {
|
||||
owsFailDebug("Missing uniqueId.")
|
||||
throw SDSError.missingRequiredField
|
||||
}
|
||||
let uniqueId: String = model.uniqueId
|
||||
|
||||
// Base class properties
|
||||
let avatarFileName: String? = model.avatarFileName
|
||||
|
||||
Loading…
Reference in New Issue
Block a user