|
|
@ -11,6 +11,7 @@
|
|
|
|
#import <YapDatabase/YapDatabaseRelationship.h>
|
|
|
|
#import <YapDatabase/YapDatabaseRelationship.h>
|
|
|
|
#import <CocoaLumberjack/DDLog.h>
|
|
|
|
#import <CocoaLumberjack/DDLog.h>
|
|
|
|
#import "CryptoTools.h"
|
|
|
|
#import "CryptoTools.h"
|
|
|
|
|
|
|
|
#import "DebugLogger.h"
|
|
|
|
#import "NSData+Base64.h"
|
|
|
|
#import "NSData+Base64.h"
|
|
|
|
|
|
|
|
|
|
|
|
#import "TSThread.h"
|
|
|
|
#import "TSThread.h"
|
|
|
@ -43,7 +44,7 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass";
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
sharedMyManager = [[self alloc] init];
|
|
|
|
sharedMyManager = [[self alloc] init];
|
|
|
|
[sharedMyManager protectDatabaseFile];
|
|
|
|
[sharedMyManager protectSignalFiles];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return sharedMyManager;
|
|
|
|
return sharedMyManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -79,32 +80,25 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass";
|
|
|
|
[self.database registerExtension:[[YapDatabaseRelationship alloc] init] withName:@"TSRelationships"];
|
|
|
|
[self.database registerExtension:[[YapDatabaseRelationship alloc] init] withName:@"TSRelationships"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
- (void)protectSignalFiles{
|
|
|
|
* Protects the preference and logs file with disk encryption and prevents them to leak to iCloud.
|
|
|
|
[self protectFolderAtPath:[TSAttachmentStream attachmentsFolder]];
|
|
|
|
*/
|
|
|
|
[self protectFolderAtPath:[self dbPath]];
|
|
|
|
|
|
|
|
[self protectFolderAtPath:[NSHomeDirectory() stringByAppendingString:@"/Library/Caches/Logs/"]];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)protectDatabaseFile{
|
|
|
|
- (void)protectFolderAtPath:(NSString*)path {
|
|
|
|
|
|
|
|
|
|
|
|
NSDictionary *attrs = @{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication};
|
|
|
|
|
|
|
|
NSError *error;
|
|
|
|
NSError *error;
|
|
|
|
|
|
|
|
NSDictionary *attrs = @{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication,
|
|
|
|
|
|
|
|
NSURLIsExcludedFromBackupKey:@YES};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[NSFileManager.defaultManager setAttributes:attrs ofItemAtPath:[self dbPath] error:&error];
|
|
|
|
BOOL success = [NSFileManager.defaultManager setAttributes:attrs ofItemAtPath:path error:&error];
|
|
|
|
[[NSURL fileURLWithPath:[self dbPath]] setResourceValue:@YES
|
|
|
|
|
|
|
|
forKey:NSURLIsExcludedFromBackupKey
|
|
|
|
|
|
|
|
error:&error];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
if (error || !success) {
|
|
|
|
DDLogError(@"Error while removing log files from backup: %@", error.description);
|
|
|
|
DDLogError(@"Error while removing files from backup: %@", error.description);
|
|
|
|
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"WARNING", @"")
|
|
|
|
SignalAlertView(NSLocalizedString(@"WARNING", @""), @"DISABLING_BACKUP_FAILED");
|
|
|
|
message:NSLocalizedString(@"DISABLING_BACKUP_FAILED", @"")
|
|
|
|
|
|
|
|
delegate:nil
|
|
|
|
|
|
|
|
cancelButtonTitle:NSLocalizedString(@"OK", @"")
|
|
|
|
|
|
|
|
otherButtonTitles:nil];
|
|
|
|
|
|
|
|
[alert show];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (YapDatabaseConnection *)newDatabaseConnection {
|
|
|
|
- (YapDatabaseConnection *)newDatabaseConnection {
|
|
|
|