From da15f245cfb09a29f6c9263d2f56558e00761d47 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 15 Feb 2018 06:20:53 -0800 Subject: [PATCH] CR: fix early return, assert on error inline functions which were only used once // FREEBIE --- SignalServiceKit/src/Util/OWSFileSystem.m | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/SignalServiceKit/src/Util/OWSFileSystem.m b/SignalServiceKit/src/Util/OWSFileSystem.m index 8b9eccb65..aaba7231b 100644 --- a/SignalServiceKit/src/Util/OWSFileSystem.m +++ b/SignalServiceKit/src/Util/OWSFileSystem.m @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN } if (!isDirectory) { - [self protectFileOrFolderAtPath:path]; + return [self protectFileOrFolderAtPath:path]; } NSString *dirPath = path; @@ -58,17 +58,6 @@ NS_ASSUME_NONNULL_BEGIN return YES; } -+ (void)logAttributesOfItemAtPath:(NSString *)path -{ - NSDictionary *_Nullable attributes = [self attributesOfItemAtPath:path]; - DDLogDebug(@"%@ path: %@ has attributes: %@", self.logTag, path, attributes); -} - -+ (nullable NSDictionary *)attributesOfItemAtPath:(NSString *)path -{ - return [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil]; -} - + (void)logAttributesOfItemAtPathRecursively:(NSString *)path { BOOL isDirectory; @@ -81,7 +70,12 @@ NS_ASSUME_NONNULL_BEGIN DDLogDebug(@"%@ path: %@ has attributes: %@", self.logTag, path, directoryEnumerator.fileAttributes); } } else { - [self logAttributesOfItemAtPath:path]; + NSError *error; + NSDictionary *_Nullable attributes = + [[NSFileManager defaultManager] attributesOfItemAtPath:path error:error]; + OWSAssert(!error); + + DDLogDebug(@"%@ path: %@ has attributes: %@", self.logTag, path, attributes); } }