Don't cull CloudKit records for lazy restoring attachments.

pull/1/head
Matthew Chen 7 years ago
parent d0c691bb7f
commit 258cdab2df

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

@ -486,9 +486,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Lazy Restore #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) { [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
id ext = [transaction ext:TSMessageDatabaseViewExtensionName]; id ext = [transaction ext:TSMessageDatabaseViewExtensionName];
if (!ext) { if (!ext) {
@ -506,10 +506,18 @@ NS_ASSUME_NONNULL_BEGIN
collection); collection);
return; 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 - (NSArray<NSString *> *)attachmentIdsForLazyRestore

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

Loading…
Cancel
Save