Skip to content

Commit c714337

Browse files
committed
optimize UploadInfoReporter func saveReportJsonString
1 parent f87f3b6 commit c714337

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

QiniuSDK/Collect/QNUploadInfoReporter.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,16 @@ - (void)saveReportJsonString:(NSString *)jsonString {
127127
return;
128128
}
129129

130+
NSFileHandle *fileHandler = nil;
130131
@try {
131132
// 上传信息写入recorder文件
132-
NSFileHandle *fileHandler = [NSFileHandle fileHandleForUpdatingAtPath:_recorderFilePath];
133+
fileHandler = [NSFileHandle fileHandleForUpdatingAtPath:_recorderFilePath];
133134
[fileHandler seekToEndOfFile];
134135
[fileHandler writeData: [finalRecordInfo dataUsingEncoding:NSUTF8StringEncoding]];
135-
[fileHandler closeFile];
136136
} @catch (NSException *exception) {
137137
NSLog(@"NSFileHandle cannot write data: %@", exception.description);
138+
} @finally {
139+
[fileHandler closeFile];
138140
}
139141
}
140142
}

0 commit comments

Comments
 (0)