Skip to content

Commit eb5ee22

Browse files
authored
Merge pull request #1922 from morganchen12/master
Invalidate sessions in completion handlers
2 parents 4fa5c7b + 0c6bc0b commit eb5ee22

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

GoogleUtilities/Network/GULNetworkURLSession.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ - (NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request
128128

129129
if (didWriteFile) {
130130
// Exclude this file from backing up to iTunes. There are conflicting reports that excluding
131-
// directory from backing up does not excluding files of that directory from backing up.
131+
// directory from backing up does not exclude files of that directory from backing up.
132132
[self excludeFromBackupForURL:_uploadingFileURL];
133133

134134
_sessionConfig = [self backgroundSessionConfigWithSessionID:_sessionID];
@@ -240,6 +240,7 @@ - (void)URLSession:(NSURLSession *)session
240240
context:error];
241241
_downloadedData = nil;
242242
}
243+
[session finishTasksAndInvalidate];
243244
}
244245

245246
#if TARGET_OS_IOS || TARGET_OS_TV
@@ -250,6 +251,7 @@ - (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session
250251
message:@"Background session finished"
251252
context:session.configuration.identifier];
252253
[self callSystemCompletionHandler:session.configuration.identifier];
254+
[session finishTasksAndInvalidate];
253255
}
254256
#endif
255257

@@ -284,6 +286,7 @@ - (void)URLSession:(NSURLSession *)session
284286
// Try to clean up stale files again.
285287
[self maybeRemoveTempFilesAtURL:_networkDirectoryURL
286288
expiringTime:kGULNetworkTempFolderExpireTime];
289+
[session finishTasksAndInvalidate];
287290
}
288291

289292
- (void)URLSession:(NSURLSession *)session

0 commit comments

Comments
 (0)