summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2018-02-21 11:32:00 -0500
committerJoel Fischer <joeljfischer@gmail.com>2018-02-21 11:32:00 -0500
commit61df343a71ca9a7f2a4da137ed01bbfb7d1c590b (patch)
tree802d94664b3380239a12fe38aa4676855576eb21
parent6054bf74fde28dc7c59114e83c743d3590987be7 (diff)
downloadsdl_ios-61df343a71ca9a7f2a4da137ed01bbfb7d1c590b.tar.gz
Fix SDLLogTargetFile bugbugs/issue_872_too_few_logs
* Allow number of files to remove to run below zero, which means the cleanup won’t run
-rw-r--r--SmartDeviceLink/SDLLogTargetFile.m6
1 files changed, 3 insertions, 3 deletions
diff --git a/SmartDeviceLink/SDLLogTargetFile.m b/SmartDeviceLink/SDLLogTargetFile.m
index f84185ebb..a7624cb88 100644
--- a/SmartDeviceLink/SDLLogTargetFile.m
+++ b/SmartDeviceLink/SDLLogTargetFile.m
@@ -111,9 +111,9 @@ NS_ASSUME_NONNULL_BEGIN
NSArray<NSString *> *sortedLogFilePaths = [self sdl_sortedLogFilePaths];
// If we have more files now than the max, remove the oldest ones
- NSUInteger filesToRemove = sortedLogFilePaths.count - maxFiles;
- for (NSUInteger i = 0; i < filesToRemove; i++) {
- NSString *path = [[self sdl_logDirectory] stringByAppendingPathComponent:sortedLogFilePaths[i]];
+ NSInteger filesToRemove = (NSInteger)sortedLogFilePaths.count - (NSInteger)maxFiles;
+ for (NSInteger i = 0; i < filesToRemove; i++) {
+ NSString *path = [[self sdl_logDirectory] stringByAppendingPathComponent:sortedLogFilePaths[(NSUInteger)i]];
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
}
}