Skip to content

Commit

Permalink
When restoring uploads, maintain the sessionUserInfo api contract.
Browse files Browse the repository at this point in the history
After using the metadata to restore things, prune out things before relaying any
sessionUserInfo value so the api contract is maintained.
  • Loading branch information
thomasvl committed Jan 16, 2025
1 parent 0c9cc25 commit 1cf4a07
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sources/Core/GTMSessionUploadFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,17 @@ + (instancetype)uploadFetcherForSessionIdentifierMetadata:(NSDictionary *)metada
// Set the upload file length before setting the upload file URL tries to determine the length.
[uploadFetcher setUploadFileLength:uploadFileLength];

// Remove the private keys (or any invalid keys) from the sessionUserInfo to maintain that api's
// type contract.
NSSet *keysToRemove = [metadata keysOfEntriesPassingTest:^BOOL(id key, id obj, BOOL *stop) {
return ![key isKindOfClass:[NSString class]] || ![obj isKindOfClass:[NSString class]] ||
[key hasPrefix:@"_"];
}];
NSMutableDictionary *sessionUserInfo = [metadata mutableCopy];
[sessionUserInfo removeObjectsForKeys:[keysToRemove allObjects]];
uploadFetcher.sessionUserInfo = sessionUserInfo;

uploadFetcher.uploadFileURL = uploadFileURL;
uploadFetcher.sessionUserInfo = metadata;
uploadFetcher.useBackgroundSession = YES;
uploadFetcher.currentOffset = currentOffset;
uploadFetcher.delegateCallbackQueue = uploadFetcher.callbackQueue;
Expand Down

0 comments on commit 1cf4a07

Please sign in to comment.