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 committed Jul 9, 2024
1 parent 348ff8c commit 95d250d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Source/santasyncservice/SNTSyncStage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ - (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 *)d.bytes, d.length))) {
NSString *errStr = @"Failed to parse response proto into message";
SLOGE(@"%@", errStr);
return [NSError errorWithDomain:@"com.google.santa.syncservice"
code:4
userInfo:@{NSLocalizedDescriptionKey : errStr}];
}
}

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

0 comments on commit 95d250d

Please sign in to comment.