Skip to content

Commit

Permalink
Add error handing to fetching a chunk from file uploads.
Browse files Browse the repository at this point in the history
This is the same logic as what happens for non-file based uploaded, it if
something happens to cause a failure to collect a subrange, then it will fail
the upload instead of the current crash that has occasionally been seen.

For both cases (Data or file based), if we can get better repos, there might be
some better checks to do in the future.
  • Loading branch information
thomasvl committed Jun 7, 2024
1 parent 029569c commit e336ec8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sources/Core/GTMSessionUploadFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,15 @@ - (void)generateChunkSubdataFromFileURL:(NSURL *)fileURL
}
if (offset > 0 || length < fullUploadLength) {
NSRange range = NSMakeRange((NSUInteger)offset, (NSUInteger)length);
resultData = [mappedData subdataWithRange:range];
@try {
resultData = [mappedData subdataWithRange:range];
} @catch (NSException *exception) {
NSString *errorMessage = exception.description;
GTMSESSION_ASSERT_DEBUG(NO, @"%@", errorMessage);
response(nil, kGTMSessionUploadFetcherUnknownFileSize,
[self uploadChunkUnavailableErrorWithDescription:errorMessage]);
return;
}
} else {
resultData = mappedData;
}
Expand Down

0 comments on commit e336ec8

Please sign in to comment.