Skip to content

Commit

Permalink
Fix a few warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
max-signal authored Jan 8, 2025
1 parent f62f6c4 commit 357e05e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,7 @@ public class QuotedReplyManagerImpl: QuotedReplyManager {
}

// Find the original message and any attachment
let (originalMessage, originalAttachmentReference, originalAttachment): (
TSMessage?,
let (originalAttachmentReference, originalAttachment): (
AttachmentReference?,
Attachment?
) = db.read { tx in
Expand All @@ -651,14 +650,14 @@ public class QuotedReplyManagerImpl: QuotedReplyManager {
transaction: SDSDB.shimOnlyBridge(tx)
)
else {
return (nil, nil, nil)
return (nil, nil)
}
let attachmentReference = attachmentStore.attachmentToUseInQuote(
originalMessageRowId: originalMessage.sqliteRowId!,
tx: tx
)
let attachment = attachmentStore.fetch(ids: [attachmentReference?.attachmentRowId].compacted(), tx: tx).first
return (originalMessage, attachmentReference, attachment)
return (attachmentReference, attachment)
}

let quoteAttachment = { () -> DraftQuotedReplyModel.ForSending.Attachment? in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ public class UnpreparedOutgoingMessage {
let unsavedBodyMediaAttachments: [AttachmentDataSource]
if quotedReplyBuilder != nil {
unsavedBodyMediaAttachments = message.unsavedBodyMediaAttachments.map {
var attachment = $0
return attachment.removeBorderlessRenderingFlagIfPresent()
return $0.removeBorderlessRenderingFlagIfPresent()
}
} else {
unsavedBodyMediaAttachments = message.unsavedBodyMediaAttachments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extension TSAttachmentMigration {
let storyAttachmentString,
let storyMessageAttachmentData = storyAttachmentString.data(using: .utf8)
else {
try reservedFileIds.cleanUpFiles()
reservedFileIds.cleanUpFiles()
continue
}
// The `attachment` column is a SerializedStoryMessageAttachment encoded as a JSON string.
Expand All @@ -89,7 +89,7 @@ extension TSAttachmentMigration {
from: storyMessageAttachmentData
)
guard let tsAttachmentUniqueId = storyAttachment.tsAttachmentUniqueId else {
try reservedFileIds.cleanUpFiles()
reservedFileIds.cleanUpFiles()
continue
}
try Self.migrateStoryMessageAttachment(
Expand Down Expand Up @@ -157,7 +157,7 @@ extension TSAttachmentMigration {
.filter(Column("uniqueId") == tsAttachmentUniqueId)
.fetchOne(tx.database)
guard let oldAttachment else {
try reservedFileIds.cleanUpFiles()
reservedFileIds.cleanUpFiles()
return
}

Expand All @@ -181,14 +181,14 @@ extension TSAttachmentMigration {
} catch {
Logger.error("Failed to read story attachment file \((error as NSError).domain) \((error as NSError).code)")
// Clean up files just in case.
try reservedFileIds.cleanUpFiles()
reservedFileIds.cleanUpFiles()
pendingAttachment = nil
}
} else {
// A pointer; no validation needed.
pendingAttachment = nil
// Clean up files just in case.
try reservedFileIds.cleanUpFiles()
reservedFileIds.cleanUpFiles()
}

let v2AttachmentId: Int64
Expand All @@ -202,7 +202,7 @@ extension TSAttachmentMigration {
// create new references to it and drop the pending attachment.
v2AttachmentId = existingV2Attachment.id!
// Delete the reserved files being used by the pending attachment.
try reservedFileIds.cleanUpFiles()
reservedFileIds.cleanUpFiles()
} else {
var v2Attachment: TSAttachmentMigration.V2Attachment
if let pendingAttachment {
Expand Down
8 changes: 2 additions & 6 deletions SignalServiceKit/Storage/Database/SDSModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ public extension SDSModel {

switch transaction.writeTransaction {
case .grdbWrite(let grdbTransaction):
do {
let record = try asRecord()
record.sdsSave(saveMode: saveMode, transaction: grdbTransaction)
} catch {
owsFail("Write failed: \(error)")
}
let record = asRecord()
record.sdsSave(saveMode: saveMode, transaction: grdbTransaction)
}

switch saveMode {
Expand Down

0 comments on commit 357e05e

Please sign in to comment.