Clean up ahead of CR.

pull/1/head
Matthew Chen 7 years ago
parent 4b7b7c19be
commit 0a6d54e8b1

@ -4,8 +4,10 @@
<dict> <dict>
<key>BuildDetails</key> <key>BuildDetails</key>
<dict> <dict>
<key>CarthageVersion</key>
<string>0.31.1</string>
<key>OSXVersion</key> <key>OSXVersion</key>
<string>10.13.6</string> <string>10.14</string>
<key>WebRTCCommit</key> <key>WebRTCCommit</key>
<string>ca71024b4993ba95e3e6b8d0758004cffc54ddaf M70</string> <string>ca71024b4993ba95e3e6b8d0758004cffc54ddaf M70</string>
</dict> </dict>

@ -520,7 +520,7 @@ NSError *OWSBackupErrorWithDescription(NSString *description)
_backupImportState = OWSBackupState_InProgress; _backupImportState = OWSBackupState_InProgress;
self.backupImportJob = [[OWSBackupImportJob alloc] initWithDelegate:self recipientId:recipientId]; self.backupImportJob = [[OWSBackupImportJob alloc] initWithDelegate:self recipientId:recipientId];
[self.backupImportJob startAsync]; [self.backupImportJob start];
[self postDidChangeNotification]; [self postDidChangeNotification];
} }

@ -8,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSBackupImportJob : OWSBackupJob @interface OWSBackupImportJob : OWSBackupJob
- (void)startAsync; - (void)start;
@end @end

@ -79,7 +79,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
return self.manifest.attachmentsItems; return self.manifest.attachmentsItems;
} }
- (void)startAsync - (void)start
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
@ -91,36 +91,24 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
[[self.backup ensureCloudKitAccess] [[self.backup ensureCloudKitAccess]
.thenInBackground(^{ .thenInBackground(^{
[self start]; [self updateProgressWithDescription:NSLocalizedString(@"BACKUP_IMPORT_PHASE_CONFIGURATION",
}) @"Indicates that the backup import is being configured.")
.catch(^(NSError *error) { progress:nil];
[self failWithErrorDescription:
NSLocalizedString(@"BACKUP_IMPORT_ERROR_COULD_NOT_IMPORT",
@"Error indicating the backup import could not import the user's data.")];
}) retainUntilComplete];
}
- (void)start
{
[self updateProgressWithDescription:NSLocalizedString(@"BACKUP_IMPORT_PHASE_CONFIGURATION",
@"Indicates that the backup import is being configured.")
progress:nil];
if (![self configureImport]) {
[self failWithErrorDescription:NSLocalizedString(@"BACKUP_IMPORT_ERROR_COULD_NOT_IMPORT",
@"Error indicating the backup import could not import the user's data.")];
return;
}
if (self.isComplete) { return [self configureImport];
return; })
} .thenInBackground(^{
if (self.isComplete) {
return
[AnyPromise promiseWithValue:OWSBackupErrorWithDescription(@"Backup import no longer active.")];
}
[self updateProgressWithDescription:NSLocalizedString(@"BACKUP_IMPORT_PHASE_IMPORT", [self updateProgressWithDescription:NSLocalizedString(@"BACKUP_IMPORT_PHASE_IMPORT",
@"Indicates that the backup import data is being imported.") @"Indicates that the backup import data is being imported.")
progress:nil]; progress:nil];
[[self downloadAndProcessManifestWithBackupIO:self.backupIO] return [self downloadAndProcessManifestWithBackupIO:self.backupIO];
})
.thenInBackground(^(OWSBackupManifestContents *manifest) { .thenInBackground(^(OWSBackupManifestContents *manifest) {
OWSCAssertDebug(manifest.databaseItems.count > 0); OWSCAssertDebug(manifest.databaseItems.count > 0);
OWSCAssertDebug(manifest.attachmentsItems); OWSCAssertDebug(manifest.attachmentsItems);
@ -129,8 +117,10 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
return [self downloadAndProcessImport]; return [self downloadAndProcessImport];
}) })
.catchInBackground(^(NSError *error) { .catch(^(NSError *error) {
[self failWithError:error]; [self failWithErrorDescription:
NSLocalizedString(@"BACKUP_IMPORT_ERROR_COULD_NOT_IMPORT",
@"Error indicating the backup import could not import the user's data.")];
}) retainUntilComplete]; }) retainUntilComplete];
} }
@ -183,18 +173,18 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
}); });
} }
- (BOOL)configureImport - (AnyPromise *)configureImport
{ {
OWSLogVerbose(@""); OWSLogVerbose(@"");
if (![self ensureJobTempDir]) { if (![self ensureJobTempDir]) {
OWSFailDebug(@"Could not create jobTempDirPath."); OWSFailDebug(@"Could not create jobTempDirPath.");
return NO; return [AnyPromise promiseWithValue:OWSBackupErrorWithDescription(@"Could not create jobTempDirPath.")];
} }
self.backupIO = [[OWSBackupIO alloc] initWithJobTempDirPath:self.jobTempDirPath]; self.backupIO = [[OWSBackupIO alloc] initWithJobTempDirPath:self.jobTempDirPath];
return YES; return [AnyPromise promiseWithValue:@(1)];
} }
- (AnyPromise *)downloadFilesFromCloud:(NSMutableArray<OWSBackupFragment *> *)items - (AnyPromise *)downloadFilesFromCloud:(NSMutableArray<OWSBackupFragment *> *)items

Loading…
Cancel
Save