Skip to content

Commit

Permalink
sync: Parse response as proto when SyncEnableProtoTransfer enabled (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
russellhancox authored Jul 9, 2024
1 parent 9e78477 commit 7f86366
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Source/santasyncservice/SNTSyncStage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@ - (NSError *)performRequest:(NSURLRequest *)request
NSData *data = [self dataFromRequest:request timeout:timeout];
if (data.length == 0) return nil;

if ([[SNTConfigurator configurator] syncEnableProtoTransfer]) {
if (!message->ParseFromString(std::string((const char *)data.bytes, data.length))) {
NSString *errStr = @"Failed to parse response proto into message";
SLOGE(@"%@", errStr);
return [NSError errorWithDomain:@"com.google.santa.syncservice"
code:4
userInfo:@{NSLocalizedDescriptionKey : errStr}];
}
return nil;
}

google::protobuf::json::ParseOptions options{
.ignore_unknown_fields = true,
};
Expand Down

0 comments on commit 7f86366

Please sign in to comment.