From 32bf9d52a1a040ebef4ad94905baa620d34050ed Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 20 Mar 2018 10:42:00 -0400 Subject: [PATCH] CR: Delete thumbnail with directory // FREEBIE --- .../src/Messages/Attachments/TSAttachmentStream.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m index e963195dd..26203f3f8 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m @@ -260,12 +260,22 @@ NS_ASSUME_NONNULL_BEGIN - (void)removeFileWithTransaction:(YapDatabaseReadWriteTransaction *)transaction { + NSError *error; + + NSString *_Nullable thumbnailPath = self.thumbnailPath; + if (thumbnailPath) { + [[NSFileManager defaultManager] removeItemAtPath:thumbnailPath error:&error]; + + if (error) { + DDLogError(@"%@ remove thumbnail errored with: %@", self.logTag, error); + } + } + NSString *_Nullable filePath = self.filePath; if (!filePath) { OWSFail(@"%@ Missing path for attachment.", self.logTag); return; } - NSError *error; [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error]; if (error) { @@ -345,7 +355,8 @@ NS_ASSUME_NONNULL_BEGIN } if (![[NSFileManager defaultManager] fileExistsAtPath:self.mediaURL.path]) { - OWSFail(@"%@ while generating thumbnail, source file doesn't exist: %@", self.logTag, self.mediaURL) return; + OWSFail(@"%@ while generating thumbnail, source file doesn't exist: %@", self.logTag, self.mediaURL); + return; } // TODO proper resolution?