Clean up ahead of PR.

pull/1/head
Matthew Chen 7 years ago
parent 51fb062af1
commit b3e6278a45

@ -186,9 +186,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendEncryptedDatabase:(TSThread *)thread + (void)sendEncryptedDatabase:(TSThread *)thread
{ {
NSString *temporaryDirectory = NSTemporaryDirectory(); NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:@"sqlite"];
NSString *fileName = [[NSUUID UUID].UUIDString stringByAppendingString:@".sqlite"]; NSString *fileName = filePath.lastPathComponent;
NSString *filePath = [temporaryDirectory stringByAppendingPathComponent:fileName];
__block BOOL success; __block BOOL success;
[TSStorageManager.sharedManager.newDatabaseConnection [TSStorageManager.sharedManager.newDatabaseConnection
@ -223,9 +222,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendUnencryptedDatabase:(TSThread *)thread + (void)sendUnencryptedDatabase:(TSThread *)thread
{ {
NSString *temporaryDirectory = NSTemporaryDirectory(); NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:@"sqlite"];
NSString *fileName = [[NSUUID UUID].UUIDString stringByAppendingString:@".sqlite"]; NSString *fileName = filePath.lastPathComponent;
NSString *filePath = [temporaryDirectory stringByAppendingPathComponent:fileName];
NSError *error = [TSStorageManager.sharedManager.newDatabaseConnection backupToPath:filePath]; NSError *error = [TSStorageManager.sharedManager.newDatabaseConnection backupToPath:filePath];
if (error) { if (error) {

@ -225,9 +225,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)createTempDatabaseFilePath - (NSString *)createTempDatabaseFilePath
{ {
NSString *temporaryDirectory = NSTemporaryDirectory(); NSString *databaseFilePath = [OWSFileSystem temporaryFilePathWithFileExtension:@"sqlite"];
NSString *filename = [[NSUUID UUID].UUIDString stringByAppendingString:@".sqlite"];
NSString *databaseFilePath = [temporaryDirectory stringByAppendingPathComponent:filename];
DDLogInfo(@"%@ databaseFilePath: %@", self.logTag, databaseFilePath); DDLogInfo(@"%@ databaseFilePath: %@", self.logTag, databaseFilePath);
[DDLog flushLog]; [DDLog flushLog];

@ -1,10 +1,11 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "DataSource.h" #import "DataSource.h"
#import "MIMETypeUtil.h" #import "MIMETypeUtil.h"
#import "NSData+Image.h" #import "NSData+Image.h"
#import "OWSFileSystem.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -173,9 +174,7 @@ NS_ASSUME_NONNULL_BEGIN
@synchronized(self) @synchronized(self)
{ {
if (!self.cachedFilePath) { if (!self.cachedFilePath) {
NSString *dirPath = NSTemporaryDirectory(); NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:self.fileExtension];
NSString *fileName = [[[NSUUID UUID] UUIDString] stringByAppendingPathExtension:self.fileExtension];
NSString *filePath = [dirPath stringByAppendingPathComponent:fileName];
if ([self writeToPath:filePath]) { if ([self writeToPath:filePath]) {
self.cachedFilePath = filePath; self.cachedFilePath = filePath;
} else { } else {

Loading…
Cancel
Save