Clean up ahead of PR.

pull/1/head
Matthew Chen 7 years ago committed by Matthew Chen
parent b3ecc085d5
commit cc10dbf32f

@ -25,10 +25,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) YapDatabaseConnection *dbConnection; @property (nonatomic, readonly) YapDatabaseConnection *dbConnection;
// This property should only be accessed on the main thread. // This property should only be accessed on the main thread.
@property (nonatomic, nullable) OWSBackupExportJob *backupExport; @property (nonatomic, nullable) OWSBackupExportJob *backupExportJob;
// This property should only be accessed on the main thread. // This property should only be accessed on the main thread.
@property (nonatomic, nullable) OWSBackupImportJob *backupImport; @property (nonatomic, nullable) OWSBackupImportJob *backupImportJob;
@property (nonatomic, nullable) NSString *backupExportDescription; @property (nonatomic, nullable) NSString *backupExportDescription;
@property (nonatomic, nullable) NSNumber *backupExportProgress; @property (nonatomic, nullable) NSNumber *backupExportProgress;
@ -222,7 +222,7 @@ NS_ASSUME_NONNULL_BEGIN
// //
// This conflict shouldn't occur in production since we won't enable backup // This conflict shouldn't occur in production since we won't enable backup
// export until an import is complete, but this could happen in development. // export until an import is complete, but this could happen in development.
if (self.backupImport) { if (self.backupImportJob) {
return NO; return NO;
} }
@ -236,18 +236,18 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
// Start or abort a backup export if neccessary. // Start or abort a backup export if neccessary.
if (!self.shouldHaveBackupExport && self.backupExport) { if (!self.shouldHaveBackupExport && self.backupExportJob) {
[self.backupExport cancel]; [self.backupExportJob cancel];
self.backupExport = nil; self.backupExportJob = nil;
} else if (self.shouldHaveBackupExport && !self.backupExport) { } else if (self.shouldHaveBackupExport && !self.backupExportJob) {
self.backupExport = self.backupExportJob =
[[OWSBackupExportJob alloc] initWithDelegate:self primaryStorage:[OWSPrimaryStorage sharedManager]]; [[OWSBackupExportJob alloc] initWithDelegate:self primaryStorage:[OWSPrimaryStorage sharedManager]];
[self.backupExport startAsync]; [self.backupExportJob startAsync];
} }
// Update the state flag. // Update the state flag.
OWSBackupState backupExportState = OWSBackupState_Idle; OWSBackupState backupExportState = OWSBackupState_Idle;
if (self.backupExport) { if (self.backupExportJob) {
backupExportState = OWSBackupState_InProgress; backupExportState = OWSBackupState_InProgress;
} else { } else {
NSDate *_Nullable lastExportSuccessDate = self.lastExportSuccessDate; NSDate *_Nullable lastExportSuccessDate = self.lastExportSuccessDate;
@ -297,27 +297,27 @@ NS_ASSUME_NONNULL_BEGIN
- (void)tryToImportBackup - (void)tryToImportBackup
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
OWSAssert(!self.backupImport); OWSAssert(!self.backupImportJob);
// In development, make sure there's no export or import in progress. // In development, make sure there's no export or import in progress.
[self.backupExport cancel]; [self.backupExportJob cancel];
self.backupExport = nil; self.backupExportJob = nil;
[self.backupImport cancel]; [self.backupImportJob cancel];
self.backupImport = nil; self.backupImportJob = nil;
_backupImportState = OWSBackupState_InProgress; _backupImportState = OWSBackupState_InProgress;
self.backupImport = self.backupImportJob =
[[OWSBackupImportJob alloc] initWithDelegate:self primaryStorage:[OWSPrimaryStorage sharedManager]]; [[OWSBackupImportJob alloc] initWithDelegate:self primaryStorage:[OWSPrimaryStorage sharedManager]];
[self.backupImport startAsync]; [self.backupImportJob startAsync];
[self postDidChangeNotification]; [self postDidChangeNotification];
} }
- (void)cancelImportBackup - (void)cancelImportBackup
{ {
[self.backupImport cancel]; [self.backupImportJob cancel];
self.backupImport = nil; self.backupImportJob = nil;
_backupImportState = OWSBackupState_Idle; _backupImportState = OWSBackupState_Idle;
@ -354,12 +354,12 @@ NS_ASSUME_NONNULL_BEGIN
DDLogInfo(@"%@ %s.", self.logTag, __PRETTY_FUNCTION__); DDLogInfo(@"%@ %s.", self.logTag, __PRETTY_FUNCTION__);
if (self.backupImport == backupJob) { if (self.backupImportJob == backupJob) {
self.backupImport = nil; self.backupImportJob = nil;
_backupImportState = OWSBackupState_Succeeded; _backupImportState = OWSBackupState_Succeeded;
} else if (self.backupExport == backupJob) { } else if (self.backupExportJob == backupJob) {
self.backupExport = nil; self.backupExportJob = nil;
[self setLastExportSuccessDate:[NSDate new]]; [self setLastExportSuccessDate:[NSDate new]];
@ -377,12 +377,12 @@ NS_ASSUME_NONNULL_BEGIN
DDLogInfo(@"%@ %s: %@", self.logTag, __PRETTY_FUNCTION__, error); DDLogInfo(@"%@ %s: %@", self.logTag, __PRETTY_FUNCTION__, error);
if (self.backupImport == backupJob) { if (self.backupImportJob == backupJob) {
self.backupImport = nil; self.backupImportJob = nil;
_backupImportState = OWSBackupState_Failed; _backupImportState = OWSBackupState_Failed;
} else if (self.backupExport == backupJob) { } else if (self.backupExportJob == backupJob) {
self.backupExport = nil; self.backupExportJob = nil;
[self setLastExportFailureDate:[NSDate new]]; [self setLastExportFailureDate:[NSDate new]];
@ -405,13 +405,13 @@ NS_ASSUME_NONNULL_BEGIN
// TODO: Should we consolidate this state? // TODO: Should we consolidate this state?
BOOL didChange; BOOL didChange;
if (self.backupImport == backupJob) { if (self.backupImportJob == backupJob) {
didChange = !([NSObject isNullableObject:self.backupImportDescription equalTo:description] && didChange = !([NSObject isNullableObject:self.backupImportDescription equalTo:description] &&
[NSObject isNullableObject:self.backupImportProgress equalTo:progress]); [NSObject isNullableObject:self.backupImportProgress equalTo:progress]);
self.backupImportDescription = description; self.backupImportDescription = description;
self.backupImportProgress = progress; self.backupImportProgress = progress;
} else if (self.backupExport == backupJob) { } else if (self.backupExportJob == backupJob) {
didChange = !([NSObject isNullableObject:self.backupExportDescription equalTo:description] && didChange = !([NSObject isNullableObject:self.backupExportDescription equalTo:description] &&
[NSObject isNullableObject:self.backupExportProgress equalTo:progress]); [NSObject isNullableObject:self.backupExportProgress equalTo:progress]);

Loading…
Cancel
Save