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];
[OWSBackupLazyRestoreJob run];
// Resume lazy restore.
[OWSBackupLazyRestoreJob runAsync];
}
- (void)registrationStateDidChange

@ -732,15 +732,16 @@ NS_ASSUME_NONNULL_BEGIN
[self.unsavedAttachmentExports removeLastObject];
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,
// it allows us to skip the local export work, i.e. encryption.
// To do so, we must preserve the metadata for these fragments.
//
// We check two things:
//
// * That the "last known backup manifest" contains an item from which we can recover
// this record's metadata.
// * That we already know the metadata for this fragment (from a previous backup
// or restore).
// * That this record does in fact exist in our CloudKit database.
NSString *lastRecordName = [OWSBackupAPI recordNameForPersistentFileWithFileId:attachmentExport.attachmentId];
OWSBackupFragment *_Nullable lastBackupFragment = [OWSBackupFragment fetchObjectWithUniqueID:lastRecordName];

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

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

@ -363,6 +363,8 @@ NS_ASSUME_NONNULL_BEGIN
if (![[NSFileManager defaultManager] fileExistsAtPath:self.mediaURL.path]) {
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;
}
@ -649,8 +651,6 @@ NS_ASSUME_NONNULL_BEGIN
[attachment setLazyRestoreFragmentId:nil];
}];
}];
[self ensureThumbnail];
}
@end

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

Loading…
Cancel
Save