Don't cull CloudKit records for lazy restoring attachments.

This commit is contained in:
Matthew Chen 2018-03-22 09:45:48 -04:00
parent d0c691bb7f
commit 258cdab2df
3 changed files with 16 additions and 7 deletions

View File

@ -75,7 +75,7 @@ typedef NS_ENUM(NSUInteger, OWSBackupState) {
#pragma mark - Lazy Restore
- (NSArray<TSAttachmentStream *> *)attachmentsForLazyRestore;
- (NSArray<NSString *> *)attachmentRecordNamesForLazyRestore;
- (NSArray<NSString *> *)attachmentIdsForLazyRestore;

View File

@ -486,9 +486,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Lazy Restore
- (NSArray<TSAttachmentStream *> *)attachmentsForLazyRestore
- (NSArray<NSString *> *)attachmentRecordNamesForLazyRestore
{
NSMutableArray<TSAttachmentStream *> *attachments = [NSMutableArray new];
NSMutableArray<NSString *> *recordNames = [NSMutableArray new];
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
id ext = [transaction ext:TSMessageDatabaseViewExtensionName];
if (!ext) {
@ -506,10 +506,18 @@ NS_ASSUME_NONNULL_BEGIN
collection);
return;
}
[attachments addObject:object];
TSAttachmentStream *attachmentStream = object;
if (attachmentStream.backupRestoreRecordName.length < 1) {
OWSProdLogAndFail(@"%@ Invalid object: %@ in collection:%@",
self.logTag,
[object class],
collection);
return;
}
[recordNames addObject:attachmentStream.backupRestoreRecordName];
}];
}];
return attachments;
return recordNames;
}
- (NSArray<NSString *> *)attachmentIdsForLazyRestore

View File

@ -1029,9 +1029,10 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(![activeRecordNames containsObject:self.manifestItem.recordName]);
[activeRecordNames addObject:self.manifestItem.recordName];
// TODO: If we implement "lazy restores" where attachments (etc.) are
// restored lazily, we need to include the record names for all
// Because we do "lazy attachment restores", we need to include the record names for all
// records that haven't been restored yet.
NSArray<NSString *> *restoringRecordNames = [OWSBackup.sharedManager attachmentRecordNamesForLazyRestore];
[activeRecordNames addObjectsFromArray:restoringRecordNames];
__weak OWSBackupExportJob *weakSelf = self;
[OWSBackupAPI fetchAllRecordNamesWithSuccess:^(NSArray<NSString *> *recordNames) {