mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.1 KiB
Objective-C
35 lines
1.1 KiB
Objective-C
#import "TSAttachmentPointer+Backups.h"
|
|
|
|
@implementation TSAttachmentPointer (Backups)
|
|
|
|
- (nullable OWSBackupFragment *)lazyRestoreFragment
|
|
{
|
|
if (!self.lazyRestoreFragmentId) {
|
|
return nil;
|
|
}
|
|
OWSBackupFragment *_Nullable backupFragment =
|
|
[OWSBackupFragment fetchObjectWithUniqueID:self.lazyRestoreFragmentId];
|
|
OWSAssertDebug(backupFragment);
|
|
return backupFragment;
|
|
}
|
|
|
|
- (void)markForLazyRestoreWithFragment:(OWSBackupFragment *)lazyRestoreFragment
|
|
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
|
{
|
|
OWSAssertDebug(lazyRestoreFragment);
|
|
OWSAssertDebug(transaction);
|
|
|
|
if (!lazyRestoreFragment.uniqueId) {
|
|
// If metadata hasn't been saved yet, save now.
|
|
[lazyRestoreFragment saveWithTransaction:transaction];
|
|
|
|
OWSAssertDebug(lazyRestoreFragment.uniqueId);
|
|
}
|
|
[self applyChangeToSelfAndLatestCopy:transaction
|
|
changeBlock:^(TSAttachmentPointer *attachment) {
|
|
[attachment setLazyRestoreFragmentId:lazyRestoreFragment.uniqueId];
|
|
}];
|
|
}
|
|
|
|
@end
|