Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent 9f866ab32b
commit 4602ad9014

@ -1135,7 +1135,8 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[OWSBackup.sharedManager setup]; [OWSBackup.sharedManager setup];
[OWSBackupLazyRestoreJob run]; // Resume lazy restore.
[OWSBackupLazyRestoreJob runAsync];
} }
- (void)registrationStateDidChange - (void)registrationStateDidChange

@ -732,15 +732,16 @@ NS_ASSUME_NONNULL_BEGIN
[self.unsavedAttachmentExports removeLastObject]; [self.unsavedAttachmentExports removeLastObject];
if (self.lastValidRecordNames) { if (self.lastValidRecordNames) {
// Wherever possible, we do incremental backups and re-use fragments of the last backup. // Wherever possible, we do incremental backups and re-use fragments of the last
// backup and/or restore.
// Recycling fragments doesn't just reduce redundant network activity, // Recycling fragments doesn't just reduce redundant network activity,
// it allows us to skip the local export work, i.e. encryption. // it allows us to skip the local export work, i.e. encryption.
// To do so, we must preserve the metadata for these fragments. // To do so, we must preserve the metadata for these fragments.
// //
// We check two things: // We check two things:
// //
// * That the "last known backup manifest" contains an item from which we can recover // * That we already know the metadata for this fragment (from a previous backup
// this record's metadata. // or restore).
// * That this record does in fact exist in our CloudKit database. // * That this record does in fact exist in our CloudKit database.
NSString *lastRecordName = [OWSBackupAPI recordNameForPersistentFileWithFileId:attachmentExport.attachmentId]; NSString *lastRecordName = [OWSBackupAPI recordNameForPersistentFileWithFileId:attachmentExport.attachmentId];
OWSBackupFragment *_Nullable lastBackupFragment = [OWSBackupFragment fetchObjectWithUniqueID:lastRecordName]; OWSBackupFragment *_Nullable lastBackupFragment = [OWSBackupFragment fetchObjectWithUniqueID:lastRecordName];

@ -162,7 +162,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
} }
// Kick off lazy restore. // Kick off lazy restore.
[OWSBackupLazyRestoreJob run]; [OWSBackupLazyRestoreJob runAsync];
[weakSelf succeed]; [weakSelf succeed];
}]; }];

@ -22,15 +22,15 @@ public class OWSBackupLazyRestoreJob: NSObject {
} }
@objc @objc
public class func run() { public class func runAsync() {
OWSBackupLazyRestoreJob().run() OWSBackupLazyRestoreJob().runAsync()
} }
public override init() { public override init() {
self.primaryStorage = OWSPrimaryStorage.shared() self.primaryStorage = OWSPrimaryStorage.shared()
} }
private func run() { private func runAsync() {
AssertIsOnMainThread() AssertIsOnMainThread()
DispatchQueue.global().async { DispatchQueue.global().async {

@ -363,6 +363,8 @@ NS_ASSUME_NONNULL_BEGIN
if (![[NSFileManager defaultManager] fileExistsAtPath:self.mediaURL.path]) { if (![[NSFileManager defaultManager] fileExistsAtPath:self.mediaURL.path]) {
DDLogError(@"%@ while generating thumbnail, source file doesn't exist: %@", self.logTag, self.mediaURL); DDLogError(@"%@ while generating thumbnail, source file doesn't exist: %@", self.logTag, self.mediaURL);
// If we're not lazy-restoring this message, the attachment should exist on disk.
OWSAssert(self.lazyRestoreFragmentId);
return; return;
} }
@ -649,8 +651,6 @@ NS_ASSUME_NONNULL_BEGIN
[attachment setLazyRestoreFragmentId:nil]; [attachment setLazyRestoreFragmentId:nil];
}]; }];
}]; }];
[self ensureThumbnail];
} }
@end @end

@ -379,6 +379,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup"
return NSOrderedSame; return NSOrderedSame;
} }
// Specific ordering doesn't matter; we just need a stable ordering.
TSAttachmentStream *attachmentStream1 = (TSAttachmentStream *)object1; TSAttachmentStream *attachmentStream1 = (TSAttachmentStream *)object1;
TSAttachmentStream *attachmentStream2 = (TSAttachmentStream *)object2; TSAttachmentStream *attachmentStream2 = (TSAttachmentStream *)object2;
return [attachmentStream2.creationTimestamp compare:attachmentStream1.creationTimestamp]; return [attachmentStream2.creationTimestamp compare:attachmentStream1.creationTimestamp];

Loading…
Cancel
Save