Backup export needs to verify that we have a valid account.

pull/1/head
Matthew Chen 7 years ago
parent 2915c533b2
commit 59fc232128

@ -187,41 +187,28 @@ NSString *const kOWSBackup_ExportDatabaseKeySpec = @"kOWSBackup_ExportDatabaseKe
OWSProdLogAndFail(@"%@ Could not create jobTempDirPath.", self.logTag); OWSProdLogAndFail(@"%@ Could not create jobTempDirPath.", self.logTag);
return completion(NO); return completion(NO);
} }
// We need to verify that we have a valid account.
// Otherwise, if we re-register on another device, we
// continue to backup on our old device, overwriting
// backups from the new device.
//
// We use an arbitrary request that requires authentication
// to verify our account state.
TSRequest *currentSignedPreKey = [OWSRequestFactory currentSignedPreKeyRequest];
[[TSNetworkManager sharedManager] makeRequest:currentSignedPreKey
success:^(NSURLSessionDataTask *task, NSDictionary *responseObject) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
completion(YES); completion(YES);
}); });
}
// TSRequest *currentSignedPreKey = [OWSRequestFactory currentSignedPreKeyRequest]; failure:^(NSURLSessionDataTask *task, NSError *error) {
// [[TSNetworkManager sharedManager] makeRequest:currentSignedPreKey // TODO: We may want to surface this in the UI.
// success:^(NSURLSessionDataTask *task, NSDictionary *responseObject) { DDLogError(@"%@ could not verify account status: %@.", self.logTag, error);
// NSString *keyIdDictKey = @"keyId"; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// NSNumber *keyId = [responseObject objectForKey:keyIdDictKey]; completion(NO);
// OWSAssert(keyId); });
// }];
// OWSPrimaryStorage *primaryStorage = [OWSPrimaryStorage
// sharedManager]; NSNumber *currentSignedPrekeyId = [primaryStorage
// currentSignedPrekeyId];
//
// if (!keyId || !currentSignedPrekeyId || ![currentSignedPrekeyId
// isEqualToNumber:keyId]) {
// DDLogError(
// @"%@ Local and service 'current signed prekey ids'
// did not match. %@ == %@ == %d.", self.logTag, keyId,
// currentSignedPrekeyId,
// [currentSignedPrekeyId isEqualToNumber:keyId]);
// }
// }
// failure:^(NSURLSessionDataTask *task, NSError *error) {
// if (!IsNSErrorNetworkFailure(error)) {
// OWSProdError([OWSAnalyticsEvents
// errorPrekeysCurrentSignedPrekeyRequestFailed]);
// }
// DDLogWarn(@"%@ Could not retrieve current signed key from the
// service.", self.logTag);
//
// // Mark the prekeys as _NOT_ checked on failure.
// [self markPreKeysAsNotChecked];
// }];
} }
- (void)exportDatabase:(OWSBackupJobBoolCompletion)completion - (void)exportDatabase:(OWSBackupJobBoolCompletion)completion

Loading…
Cancel
Save