From 6580f9112bb6e1cefc5c80ad70dc6abbd9b5c8fc Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 22 Mar 2018 09:32:22 -0400 Subject: [PATCH] Respond to CR. --- Signal/src/util/OWSBackupImportJob.m | 7 +++++++ Signal/src/util/OWSBackupJob.h | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Signal/src/util/OWSBackupImportJob.m b/Signal/src/util/OWSBackupImportJob.m index 98a3afbe9..c8abf73d7 100644 --- a/Signal/src/util/OWSBackupImportJob.m +++ b/Signal/src/util/OWSBackupImportJob.m @@ -276,6 +276,13 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe DDLogError(@"%@ skipping redundant file restore: %@.", self.logTag, dstFilePath); continue; } + NSString *dstDirPath = [dstFilePath stringByDeletingLastPathComponent]; + if (![NSFileManager.defaultManager fileExistsAtPath:dstDirPath]) { + if (![OWSFileSystem ensureDirectoryExists:dstDirPath]) { + DDLogError(@"%@ couldn't create directory for file restore: %@.", self.logTag, dstFilePath); + continue; + } + } @autoreleasepool { if (![self.backupIO decryptFileAsFile:item.downloadFilePath dstFilePath:dstFilePath diff --git a/Signal/src/util/OWSBackupJob.h b/Signal/src/util/OWSBackupJob.h index 7c72511a7..95a1fb7c9 100644 --- a/Signal/src/util/OWSBackupJob.h +++ b/Signal/src/util/OWSBackupJob.h @@ -26,7 +26,9 @@ typedef void (^OWSBackupJobManifestFailure)(NSError *error); @property (nonatomic) NSData *encryptionKey; -// This property is only set for certain types of manifest item; +// This property is only set for certain types of manifest item, +// namely attachments where we need to know where the attachment's +// file should reside relative to the attachments folder. @property (nonatomic, nullable) NSString *relativeFilePath; // This property is only set if the manifest item is downloaded.