Fix attachments.

pull/1/head
Matthew Chen 7 years ago
parent 565743b66d
commit 669a3610ab

@ -90,6 +90,10 @@
self.title = NSLocalizedString(@"SETTINGS_NAV_BAR_TITLE", @"Title for settings activity"); self.title = NSLocalizedString(@"SETTINGS_NAV_BAR_TITLE", @"Title for settings activity");
[self updateTableContents]; [self updateTableContents];
dispatch_async(dispatch_get_main_queue(), ^{
[self showBackup];
});
} }
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated

@ -284,6 +284,10 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
} }
[self updateBarButtonItems]; [self updateBarButtonItems];
dispatch_async(dispatch_get_main_queue(), ^{
[self settingsButtonPressed:nil];
});
} }
- (void)viewDidAppear:(BOOL)animated - (void)viewDidAppear:(BOOL)animated

@ -483,6 +483,10 @@ NSString *const kOWSBackup_ExportDatabaseKeySpec = @"kOWSBackup_ExportDatabaseKe
return; return;
} }
strongSelf.attachmentRecordMap[recordName] = attachmentExport.relativeFilePath; strongSelf.attachmentRecordMap[recordName] = attachmentExport.relativeFilePath;
DDLogVerbose(@"%@ exported attachment: %@ as %@",
self.logTag,
attachmentFilePath,
attachmentExport.relativeFilePath);
[strongSelf saveNextFileToCloud:completion]; [strongSelf saveNextFileToCloud:completion];
}); });
} }
@ -550,6 +554,8 @@ NSString *const kOWSBackup_ExportDatabaseKeySpec = @"kOWSBackup_ExportDatabaseKe
kOWSBackup_ManifestKey_DatabaseKeySpec : databaseKeySpec.base64EncodedString, kOWSBackup_ManifestKey_DatabaseKeySpec : databaseKeySpec.base64EncodedString,
}; };
DDLogVerbose(@"%@ json: %@", self.logTag, json);
NSError *error; NSError *error;
NSData *_Nullable jsonData = NSData *_Nullable jsonData =
[NSJSONSerialization dataWithJSONObject:json options:NSJSONWritingPrettyPrinted error:&error]; [NSJSONSerialization dataWithJSONObject:json options:NSJSONWritingPrettyPrinted error:&error];

@ -203,6 +203,8 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
return completion(NO); return completion(NO);
} }
DDLogVerbose(@"%@ json: %@", self.logTag, json);
NSDictionary<NSString *, NSString *> *_Nullable databaseRecordMap = json[kOWSBackup_ManifestKey_DatabaseFiles]; NSDictionary<NSString *, NSString *> *_Nullable databaseRecordMap = json[kOWSBackup_ManifestKey_DatabaseFiles];
NSDictionary<NSString *, NSString *> *_Nullable attachmentRecordMap = json[kOWSBackup_ManifestKey_AttachmentFiles]; NSDictionary<NSString *, NSString *> *_Nullable attachmentRecordMap = json[kOWSBackup_ManifestKey_AttachmentFiles];
NSString *_Nullable databaseKeySpecBase64 = json[kOWSBackup_ManifestKey_DatabaseKeySpec]; NSString *_Nullable databaseKeySpecBase64 = json[kOWSBackup_ManifestKey_DatabaseKeySpec];
@ -294,7 +296,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
- (void)restoreAttachmentFiles - (void)restoreAttachmentFiles
{ {
DDLogVerbose(@"%@ %s", self.logTag, __PRETTY_FUNCTION__); DDLogVerbose(@"%@ %s: %zd", self.logTag, __PRETTY_FUNCTION__, self.attachmentRecordMap.count);
NSString *attachmentsDirPath = [TSAttachmentStream attachmentsFolder]; NSString *attachmentsDirPath = [TSAttachmentStream attachmentsFolder];
@ -511,8 +513,8 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
} }
NSString *dstFilePath = [dstDirPath stringByAppendingPathComponent:dstRelativePath]; NSString *dstFilePath = [dstDirPath stringByAppendingPathComponent:dstRelativePath];
if ([NSFileManager.defaultManager fileExistsAtPath:dstFilePath]) { if ([NSFileManager.defaultManager fileExistsAtPath:dstFilePath]) {
DDLogError(@"%@ skipping redundant file restore.", self.logTag); DDLogError(@"%@ skipping redundant file restore: %@.", self.logTag, dstFilePath);
return NO; return YES;
} }
NSString *downloadedFilePath = self.downloadedFileMap[recordName]; NSString *downloadedFilePath = self.downloadedFileMap[recordName];
if (![NSFileManager.defaultManager fileExistsAtPath:downloadedFilePath]) { if (![NSFileManager.defaultManager fileExistsAtPath:downloadedFilePath]) {
@ -526,6 +528,8 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
return NO; return NO;
} }
DDLogError(@"%@ restored file: %@ (%@).", self.logTag, dstFilePath, dstRelativePath);
return YES; return YES;
} }

Loading…
Cancel
Save